I am currently trying to interface between LabView and the MSP430 receiving a character from the UART and sending a certain string based on the character received (for instance if i get an a i send the string alpha, b sends bravo, etc)
There are 3 different outputs in Lab View that correspond to the letter sent and the string to be recieved. These are controlled by switches on LabView that will constantly send a letter if turned on.
Here are my interrupts for RX and TX:
#pragma vector= USCIAB0RX_VECTOR
interrupt void USCIORX_ISR(void){
P1OUT |= RXLED; // turn on red LED
buf = UCA0RXBUF;
if(buf == 'a') //did we get an A?
{
string = a; // string = to alpha
UC0IE |= UCA0TXIE;
UCA0TXBUF = string[i++]; // send the string alpha
}
if(buf == 'b') //did we get a B?
{
string = b;
UC0IE |= UCA0TXIE;
UCA0TXBUF = string[i++]; // send the string alpha
}
if(buf == 'c') //did we get a C?
{
string = c;
UC0IE |= UCA0TXIE;
UCA0TXBUF = string[i++]; // send the string alpha
}
P1OUT &= ~RXLED;
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
P1OUT |= TXLED;
UCA0TXBUF = string[i++];
if(i == sizeof string-1)
{
UC0IE &= ~UCA0TXIE; // if end of string, stop sending//
buf = NULL;
i = 0;
}
P1OUT &= TXLED;
}
Right now 2 different things are happening.
1. the outputs in lab view will read in odd garbage chars
2. The outputs will fluctuate between the strings corresponding to the letters the
MSP430 recieves.
How may I change/improve this code to send the strings steadily to the right out puts.
(Lab view sends the letters constantly in an order based on the switch positions.
Ex: if just a is on ---> sends: 'a' 'a' 'a' ...
Ex: if a and b are on ---> sends: 'a' 'b' 'a' 'b'...
Ex: if a and b are on ---> sends: 'a' 'c' 'a' 'c'...
and anything in between)