Tool/software: Code Composer Studio
Hey, I'm a new programmer and I wanted to configure the MSP430 to blink a LED via UART. I ran into trouble setting up the register, pin ports (IO) & DCO. I know the baud rate is suppose to be 57600 bps, and the clock frequency should be 16Mhz. Is there a simple way to do this? Am going down the right path? With the Code below can I reach my goal, If yes what should I do next?
/**
* using UART to blink LED forever
* blink.c
*/
#include <msp430.h>
int ReadRegister(void);
void TestBlinkingLight(void);
int x;
int main(void)
{
while(1)
{
x = ReadRegister();
switch(x)
{
case 0x03:
TestBlinkingLight();
break;
default:
break;
}
}
}
// initialize UART
// set DCO
// Configure IO
void TestBlinkingLight(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= 0x01; // configure P1.0 as output
volatile unsigned int i; // volatile to prevent optimization
while(1)
{
P1OUT ^= 0x01; // toggle P1.0
for(i=10000; i>0; i--); // delay
}
}
int ReadRegister()
{
x = UCA0STAT;
if (0x01 == UCA0STAT)
x = UCA0RXBUF;
return x;
}