Code Composer Studio : Grace !!!

grace_logo

I recently learned about this wonderful graphical user interface(GUI) called Grace which is a part of the Code Composer Studio by Texas Instruments. I must tell you that the interface is simply amazing. I mean you can initialize all the peripherals, interrupt subroutines, interrupt handling, etc using this interface. I tried this 1 sec delay program using grace and was amazed at the fact that TI has literally make it a cake walk for programmers to initialize all peripherals and interrupts in c language. I like writing code in assembly language and for that matter even in c, but as you would come to know while programming in c you need to use some explicit functions defined by the compiler to write the various interrupt subroutines. So if you want to focus on whether your concept is correct or not and want to do testing then grace is a blessing for you. Once you know that your code is working using grace, you can anytime write the assembly language program( initializing all the peripherals using their command registers, handle the interrupt vector addresses and so on).

I’ll be covering how to make a project using grace in CCS very soon.

Advertisements

How to create a new project in CCS5.4

In this post I’m assuming you have already installed code composer studio after downloading it from http://processors.wiki.ti.com/index.php/Download_CCS. The steps involved are covered visually via images. The first step is to open the software by double clicking on its icon. Subsequent steps are shown below.

Step2

step3 step4 step5 step6 step7 step8 step9

Summary:

1) Open code composer studio.

2)Select new->project

3)Select CSS project in the dialogue box that appears

4) Since I am using msp430g2231 I have selected that ic from the list you can choose whichever ic you intend to use. Give the project a suitable na
me. You have to select an empty project with main.c else you’ll have to manually add c file which is not that difficult but I won’t be covering that in this list.

5)Make your project as active project by clicking on it in the project explorer.

6) Expand your current project by clicking on the small plus on the folder. Then double click on the main.c to open the file.

7) Now you are ready to start the c programming in main.c

8) After writing the code you can debug it. If there are no errors then you’ll get an option to run/play the program.

 

About msp430 launchpad

MSP430G2 launchpad is a development board developed by Texas Instruments. The msp430g series is a series of micro-controllers. The cost of launchpad is $9.99. This is a one time investment. Once you have the launchpad, you’ll open an entire new world for yourself. Texas Instruments launchpad contains the following hardware:

  • MSP-EXP430G2 LaunchPad
  • MSP430G2553 microcontroller (with demo code)
  • MSP430G2452 microcontroller
  • Mini-USB cable
  • Quick Start Guide
  • 32kHz external crystal

(Note: You can order the board from TI itself. The link is : http://www.ti.com/tool/msp-exp430g2 )MSP-EXP30G2.jpg

Texas provides free samples of these microcontrollers. So whenever you’ll need a microcontroller, you can search their website and order free sample of whatever you like. This enables to divert you money into other electronic equipment that you require. All in all I encourage all of you people out there who like coding and controllers to get your hands on launchpad.

P.S: If you have any query regarding how to order these samples, feel free to contact me.

Blinking LED(hello world! of micro controllers)

This post is about the blinking led’s. Those of you who know c/c++/java or any programming language for that matter would have definitely written the first program as hello world. In case of micro controllers blinking led’s is the hello world sort of thing.

Theory:

On launchpad there are two surface mount led’s (smd led’s), they differ from normal led’s in the sense that there are tiny as compared to the normal ones. We generally use current limiting resistors while using led’s of any sort, but Texas has taken care of that for us already by connecting these on board led’s with current limiting smd resistors. We make use of port 1 pins 0 and 6 to which these led’s are connected. When the port is made high the led glows and when its made low the led turns OFF. Thus we first configure the P1.0 and P1.6 pins as output pins using the direction register. Then we toggle the output register after some delay so that the change is registered by human eyes(persistence of vision remember??).

Code:

//Author: Manpreet Singh Minhas
//Date : 2/10/2013
//learningmsp430.wordpress.com
#include <msp430g2211.h>// include the header file for msp430g2211
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;                                                                          //stop watchdog timer
P1DIR|=BIT0+BIT6;                                                                                                    //set the port 1 pin 0 and pin 6 as output you can do this by using hex                                                                                                                                              *command word as well i.e 01000001 or 0x041 or 41h
P1OUT|=BIT0; // make port1 pin0 i.e P1.0 high
int i=0;
for(;;){                                                                                                                               // infinite loop so that the action is repeated indefinitely

P1OUT ^= (BIT0+BIT6);                                                                                                 // toggle using ex-or with 1 ( refer truth table of ex-or operation.)
for(i=0;i<20000;i++){

// some delay for the human eye to observe the change
}

}
}

Video:

*: Those of you who don’t know what is a command word. Command word is 8bit or 16 bit data that is given to the special function registers to configure the device how we want. In this case it is the P1DIR and P1OUT registers. Thus these two are command word registers and the data we send is command word. In msp430g2xx1 making P1DIR.x high/1 makes the port pin as output and low/0 makes it input. P1OUT makes the port high if the bit is set and makes it low if the bit is reset.

Led patterns using msp430g2231

led-patterns
This application is generation of led patterns using msp430g2231.
Components Required:
msp430g2231 (1)
1k resistors (8)
preset 4.7k (1)
rgb led 2pin (8)
berg wires (8/9)
toggle switch(1)
705009_RB_00_FB.EPS_1000

Theory:
In this application we utilize all 8 ports of the micro-controller. Each port is connected to one of the led’s via current limiting resistors. Now all we need to do is set all the ports as output and then change the patterns by varying the port pins that are high/low. We are using code composer studio for this. The program is written in c. We can either use the launchpad directly for connections via breadboard or we can make a PCB for it. The advantage of PCB is that you can carry is with you without having to take the launchpad as well your laptop with you. Or you can build a shield/booster pack of led’s like in the image shown below.

021020131203

Code:
#include
main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0XFF; // set all the ports as output ports
int x = 0X01;
long i=0;
int j=1;
int k=0;
int l=0;
for(;;)
{

for(k=1;k<=5;k++){
x=0x01;
for(j=1;j<=8;j++){

P1OUT = x;
x*=2;
for(i=0;i<=10000;i++)
{
}
}
}
for(k=1;k<=5;k++){
x=0x80;
for(j=1;j<=8;j++){

P1OUT = x;
x/=2;
for(i=0;i<=10000;i++)
{
}
}
}

for(k=1;k<=5;k++){

P1OUT=0xAA;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
P1OUT=0x55;
for(l=0;l<=1;l++){
for(i=0;i<=64000;i++)
{}}
}

for(k=1;k<=5;k++){

P1OUT=0x18;

for(i=0;i<=20000;i++)
{}
P1OUT=0x24;

for(i=0;i<=20000;i++)
{}
P1OUT=0x42;

for(i=0;i<=20000;i++)
{}
P1OUT=0x81;

for(i=0;i<=20000;i++)
{}

}
for(k=1;k<=5;k++){

P1OUT=0x81;

for(i=0;i<=20000;i++)
{}
P1OUT=0x42;

for(i=0;i<=20000;i++)
{}
P1OUT=0x24;

for(i=0;i<=20000;i++)
{}
P1OUT=0x18;

for(i=0;i<=20000;i++)
{}

}

}
}

My instructable link:

http://www.instructables.com/id/LED-patterns-using-msp430-launchpad/

YouTube Video:
http://www.youtube.com/watch?v=g9NRDXL0vOk

Note: If anyone wants the PCB file, just let me know.