Thursday, November 10, 2011

Beginning MSP430 Microcontroller with Launch Pad


 introduction to the TI MSP430 low-power microcontrollers

Overview

The MSP430 is a very clean 16-bit byte-addressed processor with a 64K unified address space, and memory-mapped peripherals. The current family includes a variety of on-chip peripherals, and ranges from a 20-pin package with 1K of ROM and 128 bytes of RAM to 100-pin packages with 60K of ROM and 2K of RAM. Devices with greater RAM and ROM, and additional peripheral blocks are in development.

The MSP430 excels where low power consumption is important. Many applications, such as water meters, are currently achieving more than 10 years operation from a single button cell battery. If low power is not critical, well, the MSP430 is a nice elegant device to use, anyway. It programs very well in C, making assembly language programming unnecessary. There is no memory bank switching to make the compiler's life difficult; it uses normal RAM for its stack; it has a clean 16 bit instruction set. In fact, it is somewhat like an ordinary desktop RISC processor, but requires very little power.


Flashing the two on board led alternately  :- the adventure begin 


    so now without wasting let's start by step 1

Step 1 – Installation of Code composer studio (IDE for TI mcu)

Download and install Code Composer Studio. code composer studio is free up to 16 KB for flash mcu. because all MSP430 value line parts have max 16 KB flash so free version is best for us 

Step 2:- Creating the project under CCS (Code composer studio)
           Run CCS and you will be prompted where you want to put your workspace. Within one workspace you can have multiple projects so I recommend making a directory where you will keep all your different projects code. I chose to use this directory as default but you don’t have to.

Now click Project-> New CCS project

Now you will see the New CCS Project Dialog box 
in this dialog you have to give specify two things  
1:- Project name :- project name may be anything you like 
2:- Device :- Device is actually nothing but the microcontroller  we are using ,, in our project we will be useing MSP430 device family's MSP430G2211 (which is supplied with MSP430 Launchpad).

after selecting all this just click Finish 

Now your new project is created , you will see your project as Active in the Project explorer window at the  left side of IDE.

in this active project just double click on main.c file  , this file will be opened for editing at the center of the screen as shown in the figure blow. actually main.c is the file where you will write all of your source code.

Step 3 – Writing the code 

      
        now we will start  writing our code in the main.c file under the line //code goes here 

There are tow LED on the board Red on      PORT1 .0  and  Green on PORT1.6 
we will flash them alternately 

#include <msp430g2211.h>

void main(void)
{
//code goes here
volatile unsigned int i;
P1DIR = 0xFF;       //set port p1 as output 
P1OUT = 0x00;       // set Port p1 as low
P1OUT ^= BIT6;      // invert the green led 

while(1)
{

                     P1OUT ^= BIT0;      //to invert the led on port P1.0 (Red)
                     P1OUT ^= BIT6;      //to invert the led on port P1.6 (Green)
                     for(i=0;i<=30000;i++);   //to generate some delay 

}
}


your code is ready to go now take your launch pad out of the box 


The Launch pad LED


Running the Code :-
to run the code click on the green bug in the tool bar 
as shown in the figure blow. 
this will take you to debug prospective of the CCS IDE 
The Debug Prospective 


when you enter debug prospective the ide will automatically load the firmware file to the launch pad 

Now just click on the Resume button 
now led will start flashing alternately .
you can also execute the instruction step by step by clicking setp into button on the debug toolbar.
view in oscilloscope 


Download the source code




you may also like  MSP430 BASED 30V VOLT METER

No comments:

Post a Comment