Wednesday 2 November 2011

INTRODUCTION TO MSP430

                                                            The Texas Instruments MSP430 is a series of ultra low power micro controllers which  I have come across as a very low price development of board of Texas Instruments called launchpad. MSP430 has a powerful 16 bit RISC processor which has 16 bit general purpose registers and a constant generator. I have come across the MSPs G series of micro controllers which had a the following features.
 *) 16 timer.
*) 10 bit ADC
*) 2 IO PORTS.
*) I2C
*) SPI


 Setting up a Linux development environment.
                                          For compiling the C programs you have to install the tool chain which includes cross compilers, assemblers . In linux you have two options you can either build the cross compiler from source and install it to or you can search for a binary file. The first one may take some time and you may get messed up with some nasty errors . If you want to do it in a hard way you can go for it, in my case I would be select the easy one . I got the binary of the msp430-gcc,msp430-binutils etc from the following site The package was for ubuntu . I am using debian and that packages worked for me. You can download the packages from that site and install them . After installing the tool chain you will have to install another tool "mspdebug" which is used for debugging and burning the code to the micro controller.
 Led Blinking Code
#include<msp430.h>
void sleep(int i)
{
 while(i--);
}

void main(void)
{
 WDTCTL = WDTPW | WDTHOLD;
 P1DIR = 0xFF;
 while(1) {
   P1OUT ^= 0x01;
   sleep(50000);
 }
}
In the main function first line of the code disables the watch dog timer. next we have to set the direction of the i/o port 1 as the out-put port . After setting port-1 as output port we just toggle the first pin of the i/o port 1.
 compiling the code
To compile the above code you can use the cross compiler which is msp430-gcc
tonylijo@tonylijo:~$ msp430-gcc new.c
after executing the command you will get a file a.out. 
Burning the code to the Micro controller
                                                To burn the code to micro controller you have to use the tool mspdebug after executing the command you will get like given below.
root@tonylijo:/home/tonylijo# mspdebug rf2500
MSPDebug version 0.16 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2011 Daniel Beer dlbeer@gmail.com
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Trying to open interface 1 on 003
rf2500: warning: can't detach kernel driver: No data available
Initializing FET...
FET protocol version is 30001000
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
fet: FET returned error code 4 (Could not find device (or device not supported))
fet: command C_IDENT1 failed
fet: identify failed
Trying again...
Initializing FET...
FET protocol version is 30001000
Configured for Spy-Bi-Wire
Sending reset...
Set Vcc: 3000 mV
Device ID: 0xf201
Device: MSP430G2231
Code memory starts at 0xf800
Number of breakpoints: 1

Available commands:
    =         delbreak  gdb       load      opt       reset     simio     
    alias     dis       help      locka     prog      run       step      
    break     erase     hexout    md        read      set       sym       
    cgraph    exit      isearch   mw        regs      setbreak  

Available options:
    color           gdb_loop        iradix          
    fet_block_size  gdbc_xfer_size  quiet           

Type "help topic" for more information.
Press Ctrl+D to quit.
(mspdebug)
after that to erase the code which is currently inside the micro controller you can use the command erase to burn the code to the micro controller you can use the command
(mspdebug) prog a.out

No comments:

Post a Comment