Hi! I’m new with msp430f169 and I want to write a simple application to blink a led at various speed. In windows part, there is a button to start blinking and a trackbar to change blinking speed. Variables (like blinking speed) are converted into strings then sent to serial port. In msp430 part, I want to take the values from serial port and compare them, do the operation; but the program doesn’t work? Can you help me? What is wrong with this code?
#include <msp430x16x.h>
void blinker (unsigned int);
unsigned int a=100;
char m[1];
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL |= 0xC0; // P3.6,7 = USART1 option select
ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD
//ME1 |= UTXE0 + URXE0;
UCTL1 |= CHAR; // 8-bit character
UTCTL1 |= SSEL0; // UCLK = ACLK
UBR01 = 0x0D; // 32k/2400 - 13.65
UBR11 = 0x00;
UMCTL1 = 0x6B; // Modulation
UCTL1 &= ~SWRST; // Initialize USART state machine
IE2 |= URXIE1; // Enable USART1 RX interrupt
//BTCTL = BTDIV + BT_fCLK2_DIV4;
// Mainloop
for (;;)
{
_BIS_SR(GIE); // Enter LPM3 w/interrupt
blinker (a);
}
}
//#if 1
// UART1 RX ISR will for exit from LPM3 in Mainloop
#pragma vector= USART1RX_VECTOR
__interrupt void usart1_rx (void)
{
//_BIC_SR_IRQ(LPM3_bits);// Clear LPM3 bits from 0(SR)
m[0]=RXBUF1;
switch(m[0]){
case 'A':
blinker(a);
case '1':
a=100;
case '2':
a=500;
case '3':
a=1000;
case '4':
a=5000;
case '5':
a=10000;
}
}
//#endif
void blinker(unsigned int m)
{
while (m>0);{
P5OUT ^= 0x02;
m--;
}}