Hello...
I have four 8 byte messages I would like to send to a radio. I notice that I am sending 7, 7, 7, 8 on a logic analyzer....The last byte of each of the first three blocks of data is getting cutoff and not sent....My code is as follows:
else if (Button == DEFINE_SYS) { for (sysLoop = 0; sysLoop < 4; sysLoop++) { mssg[4] = sysID[2*sysLoop]; mssg[5] = sysID[2*sysLoop + 1]; mssg[6] = crc[2*sysLoop]; mssg[7] = crc[2*sysLoop + 1]; TB0CCR2 = TB0R + 1; TB0CCTL2 |= CCIE; LPM3; while (!UCTXCPTIFG); }
I notice that if I remove
while (!UCTXCPTIFG);
and replace with __delay_cycles(10000); that all eight bytes of each message get sent out....
The code is supposed to work as follows:
Create 8 byte message....wait for 80ms....transmit 8 bytes over UART and then wake to create second message...go to sleep and wait for 80ms again....
I see two issues which I don't understand at the moment.
1. the first seven bytes go out but not the eighth byte on first three messages?
2. the bytes are ALL back to back with no 80ms window between each?
Can someone tell me something to look for? I was trying to use the UCTXCPTIFG because I was thinking the LPM3 was waking due to another ISR (possibly one of the TBxIFG flags).
The other code section look as follows:
80ms wake up
case TB0IV_TBCCR2: TB0CCR2 = TB0R + TX_MESSAGE_SPACING_TIME; if (remote) { pTx = mssg; TB0CCTL2 &= ~CCIE; UCA1IFG |= UCTXIFG; UCA1IE |= UCTXIE; } break;
TX ISR: (the else portion is only valid here)
case USCI_UART_UCTXIFG: if (radioConfiguration) LPM3_EXIT; else { UCA1TXBUF = *pTx; pTx++; if (pTx > (mssg + 7)) { UCA1IE &= ~UCTXIE; UCA1IFG &= ~UCTXIFG; LPM3_EXIT; } } break;
One final thought....baud rate is 19.2k with 1 start bit and 1/2 bit for stop.....8 bytes is well within the 80ms period.
Thanks