Hi, I'm working with the Texas TSM320F062, interfacing with Xbee module by UART port. So, I should be capable of capture a string, looks like "7E 00 11 00 46 ....." start byte always it's 0x7E, but I need advice for reliable system for capture entire strings. Also, it has a variable number of bytes, so I can receipt either 8 or 25 byte.
Then, I have this:
__interrupt void sciaRxFifoIsr(void) { i++; Received_Char = SciaRegs.SCIRXBUF.all; SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack }
In the main void, I wait to recive a 0X7E, then clear counter i. Like this:
ReceivedChar[i] = Received_Char; if (ReceivedChar[i] == 0x7E) {i = 0;} Delimiter = ReceivedChar[1]; MSB = ReceivedChar[2]; LSB = ReceivedChar[3]; lenght = MSB + LSB; lenght = lenght + 1;
It's very important for me, know the correct position for the all bytes, how you can see, I used the variable "lenght" for calculate the checksum. But this doesn't works correctly, because some times I loose, the start byte.
best regards
Alejandro