0% found this document useful (0 votes)
99 views23 pages

Ti Manual

The document describes 10 steps for using Code Composer Studio to write and debug programs for the MSP432 microcontroller. It includes steps for creating a project, writing code, building the project to check for errors, debugging the program step-by-step, and executing the program continuously on the launch board. It also describes how to add SDK libraries to include files and driver libraries to the file search path.

Uploaded by

N Sornakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views23 pages

Ti Manual

The document describes 10 steps for using Code Composer Studio to write and debug programs for the MSP432 microcontroller. It includes steps for creating a project, writing code, building the project to check for errors, debugging the program step-by-step, and executing the program continuously on the launch board. It also describes how to add SDK libraries to include files and driver libraries to the file search path.

Uploaded by

N Sornakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

METHOD 1

Getting start with code composer studio V6.0


Step1: Open the code composer studio software.

Step2: Click New CCS Project under projects.


Step3: Select the target As MSP432 Family

Step4: Select the Generic ARM7 device as MSP432P401R.

Step5: Create a project name and click Finish.


Step6: Thus the project is created; the program is to be written under the main.c as shown
below.

Step7: Now click Build All under project to build the project to check for any errors.
Step8: Now click Debug under run to debug the program step by step before executing in
the device.

Note: The program gets downloaded onto the launch board

Step9: The compiler goes to debug mode and Green color LED glows in the launch board
resembling that the launch board is in debug mode.
Note: Notice the pointer point the main function of the program as indicated in the arrow
mark below.
Step10: Now press F5(Step) for step by step execution of the program and notice that
depending upon the step by step execution the pointer moves one line after the another in
the program and the launch board output executes depending upon the instruction executed
in the program for example the above program is a LED blinking program in which Port2 is
made as GPIO output in the line 6 to 8 and is made high at line 11 hence if line 11 is
executed the P2.1 GREEN LED starts to glow in the launch board. Hence using debug mode
real time execution can be done step by step.

Note: The delay


routines can be
skipped by clicking
F6 (Step over)

Step11: Click the red termination button to terminate the debug session and move to
continuous execution mode

Note: the GREEN debug led stops and the program starts to execute continuously in
this case the P2.1 starts to blink.
METHOD 2

Procedure to add SDK libraries to the include files:

Check for the SDK files in the linked resources:

Verify the connector of TI microcontroller:


If SDK exe file is installed in your PC then only it will show in add option.If not,install it and then start
with the following procedure.
After addition,check for the linked resources,simple link is
included in linked resources section.

Include the path & directory source files to


the include options available under ARM
compiler.
Deselect all the options shown under ULP
advisor.
Check for Simple link SDK library file & driver
library addition in file search path otherwise
add it.
Add the file by browse option.
Driver library available in
C:\ti\simplelink_msp432p4_sdk_2_30_00_14\source\ti\devices\msp432p4xx\driverlib\cc
s\msp432p4xx_driverlib.lib
Method 1 Programs:

1. LED BLINKING
#include <ti/devices/msp432p4xx/driverlib/driverlib.h> //header file
int main(void)
{
int i;
GPIO_setAsOutputPin(GPIO_PORT_P6,GPIO_PIN4); //port6,4th pin output pin
while(1)
{
GPIO_setOutputHighOnPin(GPIO_PORT_P6,GPIO_PIN4); //P6.4 Is high
for(i=0;i<300000;i++);
GPIO_setOutputLowOnPin(GPIO_PORT_P6,GPIO_PIN4); //P6.4 Is low
}
}

2. LED Controlled By switch

#include <ti/devices/msp432p4xx/driverlib/driverlib.h> //header file


int main(void)
{
GPIO_setAsOutputPin(GPIO_PORT_P6,GPIO_PIN4); //port6,4th pin output pin
GPIO_setAsInputPin(GPIO_PORT_P4,GPIO_PIN3); //port4,3rd pin input pin
while(1)
{
if(GPIO_getInputPinValue(GPIO_PORT_P4,GPIO_PIN3)==1)//switch is pressed
{
GPIO_setOutputHighOnPin(GPIO_PORT_P6,GPIO_PIN4); //P6.4 Is high
}
else //else
{
GPIO_setOutputLowOnPin(GPIO_PORT_P6,GPIO_PIN4); //P6.4 Is low
}
}
}
Method 1 Programs:

1. LED BLINKING
#include "msp.h" //header file
void main(void) //main function
{
int i;
P6->SEL1 &= ~0x10; //port6,4th pin as GPIO Pin
P6->SEL0 &= ~0x10;
P6->DIR |= 0x10; //set port6,4th pin consider as output
while(1)
{
P6->OUT |=0x10; //led on
for(i=0;i<300000;i++);
P6->OUT &=~0x10; //led of
}
}

2. LED controlled By Switch


#include "msp.h" //header file
void main(void) //main function
{
int a;
P6->SEL1 &= ~0x10; //port6,4th pin and port4,3rd pin as GPIO Pins
P6->SEL0 &= ~0x10;
P4->SEL1 &= ~0x08;
P4->SEL0 &= ~0x08;
P6->DIR |= 0x10; //set port6,4th pin consider as output
P4->DIR &= ~0x08; //set port4,3rd pin consider as input
while(1)
{
if(a=P4->IN&0x08) //switch is pressed
{
P6->OUT |=0x10; //led on
}
else // else
{
P6->OUT &=~0x10; //led of
}
}
}

3. 7Segment display interfacing with max7219

#include <msp.h>
void delay(unsigned int time) //delay function
{
int j,i;
for(j=0;j<time;j++)
{
for(i=0;i<1000;i++);
}
}
void send(int address, int data) //send data function
{
int j,temp;
P4->OUT &= ~0X10; //serial clock low
P4->OUT &= ~0X20; //chip select low
for (j = 0; j < 8; j++) //Transfer of 8 bits
{
temp = address;
if ((temp & 0x80) == 0x80) //if MSB of data is high
{
P4->OUT |= 0X80; //data is high
}
else
{
P4->OUT &= ~0X80; //data is low
}
address = address<<1; //Left shift of data
P4->OUT |= 0X20; //serial clock high
delay(1);
P4->OUT &=~ 0X20; //serial clock low
delay(1);

}
for (j = 0; j < 8; j++) //Transfer of 8 bits
{
temp = data;
if ((temp & 0x80) == 0x80) //if MSB of data is high
{
P4->OUT |= 0X80; //data is high
}
else
{
P4->OUT &= ~0X80; //data is low
}
data= data<<1; //Left shift of data
P4->OUT|=0X20; //serial clock high
delay(1);
P4->OUT&=~0X20; //Serial clock low
delay(1);
}
P4->OUT|=0X10; //chip select high
delay(1);
P4->OUT&=~0X10; //chip select low
delay(1);
}
void maxiniti()
{
int i;
int a[3]={0x0C,0x0A,0x09};
int b[3]={0x01,0x03,0xFF};
for(i=0;i<3;i++)
{
send(a[i],b[i]);
delay(1);
}
}
void main()
{

int i,k,tmp,n,dispv;
P4->SEL1 &= ~0x10;
P4->SEL0 &= ~0x10;
P4->SEL0 &= ~0x20;
P4->SEL1 &= ~0x20;
P4->SEL0 &= ~0x80;
P4->SEL1 &= ~0x80;

P4->DIR|= 0xB0; //port4,4th,5th,8th pin consider as output

P4->OUT |=0X10; //chip select


maxiniti();
for(i=0;i<999;i++)
{
tmp = i;
if (tmp <10)
n=0;
else if ((tmp >=10) && (tmp <100))
n=1;
else
n=2;
send(0x0b,n);
for (k = 1; (k <= (n+1)); k++)
{
dispv = tmp % 10;
send(k, dispv);
tmp = (tmp / 10);
}
delay(10);
}
}

4. LCD Interfacing with TI

#include "msp.h"
void delay_ms() // 1ms delay function
{
int i,j;
for(i=0;i<1;i++)
{
for(j=0;j<3000;j++);
}
}
void delay_us() //1us delay function
{
int i,j;
for(i=0;i<1;i++)
{
for(j=0;j<3;j++);
}
}
void i2ciniti()
{
P4->OUT|=0X04; //SDA As high
P4->OUT|=0X01; //SCL As high
}
void i2cstart()
{
P4->OUT&=~0X04; //SDA As low
delay_ms();
P4->OUT&=~0X01; //SCL As low
}
void send_data(int data_)
{
int i,temp,temp1;
for(i=0;i<8;i++)
{
temp=data_;
temp1=temp&0x80;
P4->OUT&=~0X01; //SCL As low
if(temp1==0x80)
{
P4->OUT|=0X04; //SDA As high
}
else
{
P4->OUT&=~0X04; //SDA As low
}
delay_us();
data_=data_*2;
P4->OUT|=0X01; //SCL As high
}
delay_us();
P4->OUT&=~0X01; //SCL As low
delay_us();
P4->OUT|=0X04; //SDA As high
delay_us();
P4->OUT|=0X01; //SCL As high
delay_us();
P4->OUT&=~0X01; //SCL As low
delay_us();
}
void i2cstop()
{
P4->OUT&=~0X01; //SCL As low
delay_ms();
P4->OUT&=~0X04; //SDA As low
delay_ms();
P4->OUT|=0X01; //SCL As high
delay_ms();
P4->OUT|=0X04; //SDA As high
}
void lcddata(char dat)
{
char hin, lon;
char rs = 0x01; //assign rs as high
hin = dat & 0xF0; // masking higher nibble bit
lon = (dat << 4) & 0xF0; // masking lower nibble bit
i2cstart();
send_data(0x4E); /*0100 1110 -- LHLL HHHL O th bit is low so
it's write operation, (1st,2nd,3rd) bit is high so A0,A1,A2 is high so choose the
control Command of pcf8457 is 4E*/
send_data(hin | rs | 0x04 | 0x08); //enable pin high for higher nibble bit
delay_us();
send_data(hin | rs | 0x00 | 0x08); //enable pin low for higher nibble bit
delay_us();
send_data(lon | rs | 0x04 | 0x08); //enable pin high for lower nibble bit
delay_us();
send_data(lon | rs | 0x00 | 0x08); //enable pin low for lower nibble bit
i2cstop();
}
void lcdcmd(char cmd)
{
char hin, lon;
char rs = 0x00; //assign rs as low
hin = cmd & 0xF0; // masking higher nibble bit
lon = (cmd << 4) & 0xF0; // masking lower nibble bit
i2cstart();
send_data(0x4E); /*0100 1110 -- LHLL HHHL O th bit is low so
it's write operation, (1st,2nd,3rd) bit is high so A0,A1,A2 is high so choose the
control Command of pcf8457 is 4E*/
send_data(hin | rs | 0x04 | 0x08); //enable pin high for higher nibble bit
delay_us();
send_data(hin | rs | 0x00 | 0x08); //enable pin low for higher nibble bit
delay_us();
send_data(lon | rs | 0x04 | 0x08); //enable pin high for lower nibble bit
delay_us();
send_data(lon | rs | 0x00 | 0x08); //enable pin low for lower nibble bit
i2cstop();
}
void lcdinit()
{
delay_ms();
i2cstart();
send_data(0x4E); /*0100 1110 -- LHLL HHHL O th bit is low so it's write
operation, (1st,2nd,3rd) bit is high so A0,A1,A2 is high so choose the control
Command of pcf8457 is 4E*/
delay_ms();
send_data(0x2C);
delay_us();
send_data(0x28); // 4bit mode operation
i2cstop();
delay_ms();
lcdcmd(0x01); //clear the screen
lcdcmd(0x06); //entry mode
}
void main(void)
{

char first[15] = "EMBEDDED SYSTEM";


int k;
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop WDtimer
P4->SEL1&=~0x04; //SDA configure as simple I/o
P4->SEL0&=~0X04; //SDA
P4->SEL0&=~0x01; //SCL
P4->SEL1&=~0x01; //SCL
/* SDA and SCL consider as output */

P4->DIR|=0X04; //SDA As output


P4->DIR|=0X01; //SCL As output

i2ciniti();
lcdinit();

lcdcmd(0x80);
for(k=0;k<15;k++)
{
lcddata(first[k]);
}
while(1);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy