Can someone tell me how to get around the following: I produce a command, a radio echoes the command back I then produce "ACK" however my code is producing "AACK"....I am not sure how to get around this or for that matter why A is occurring twice...If I try and load the UCA1TXBUF outside the ISR it does not help???
The code:
#include <msp430.h>
#include <string.h>
#include <stdint.h>
#include "rc.h"
#include "LPRSradio.h"
volatile char *pRx;
char incoming[20];
const char *pTx;
const char *configCmdAck[] = {"ER_CMD#a01", "ER_CMD#W2", "ER_CMD#b1"};
const char *testack = "ACK";
uint8_t i = 0;
boolean tx = T;
int k;
boolean redflag = F;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
IOconfig;
initClockTo16MHz();
initUART();
pRx = incoming;
pTx = configCmdAck[0];
while (1)
{
__bis_SR_register(LPM3_bits + GIE); //go to sleep: LPM3
if (tx) {
pTx++;
}
else {
if (!strncmp(incoming, configCmdAck[i], 10))
{
pTx = testack;
i++;
UCA1IFG |= UCTXIFG;
}
pRx++;
}
}
}
#pragma vector=USCI_A1_VECTOR
__interrupt void M(void)
{
switch(__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
tx = F;
*pRx = UCA1RXBUF;
__bic_SR_register_on_exit(LPM3_bits);
break;
case USCI_UART_UCTXIFG:
tx = T;
if (*pTx != '\0')
UCA1TXBUF = *pTx;
__bic_SR_register_on_exit(LPM3_bits);
break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}
The pic: