Tool/software: Code Composer Studio
Dear Gracious community members,
I am trying to read data from UART in serial terminal, only when propmted; aka serial communication protocols used by almost all the available devices. Now when I send the appropriate command, the microprocessor starts a continous stream of repeted information. What I would like is, only one instance of this information, each time I send the command. I have attached the code below.
Any help would be much apprecited.
Thank you.
With Warm Regards
Subhronil
#include <msp430.h>
#include <math.h>
#include <stdio.h>
void main (void)
{
WDTCTL = WDTPW | WDTHOLD;
char str[] = "The Answer is: ";
char check = 'a'; // the command
P1DIR |= BIT0;
//USCI setup Code =========================================================================================
P4SEL |= 0x30;
UCA1CTL1 |= UCSWRST;
UCA1CTL1 |= UCSSEL_1;
//UCA1CTL1 |= UCBRKIE_1;
UCA1BR0 = 3;
UCA1BR1 = 0x00;
UCA1MCTL = 0x06;
UCA1CTL0 = 0x00;
UCA1IE = 0x01;
UCA1CTL1 &= ~UCSWRST;
//the main loop**********************************************************************************************
for(;;)
{
int i = 0;
UCA1CTL1 |= UCSWRST;
UCA1CTL1 &= ~UCSWRST;
if ((UCA1RXBUF == check)&(UCRXIFG))
{
while(str[i] != '\0') // send the first String
{
UCA1TXBUF = str[i];
while (UCA1STAT&UCBUSY);
i++;
}
UCA1TXBUF = 0x0a; // for next line
while (UCA1STAT&UCBUSY);
UCA1TXBUF = 0x0d; // for next line
while (UCA1STAT&UCBUSY);
}
else
P1OUT ^= 0x01;
__delay_cycles(75000);
}
}