Tool/software: Code Composer Studio
Hi,
In the following test setup, two system A & B are connected via UART/Xbee radio.
System A (MSP430 + UART/Xbee Radio) ---> System B (PC + Xbee with USB adapter)
System A repeatedly packs a hard coded variable(INT16)and message count, checksum into a message, then sends out to System B via UART.
void xbeeSendIntAT(char moduleIdentifier, char msg_type, char port, char sensor_type, int data) { unsigned char tempArray[2]; tempArray[0] = (data >> 8) & 0xFF; tempArray[1] = data & 0xFF; xbeeSendmsgAT(moduleIdentifier, msg_type, port, sensor_type, tempArray, 2); } void xbeeSendmsgAT(char moduleIdentifier, char msg_type, char port, char sensor_type, unsigned char data[], char dataLen) { char i; unsigned char msg[48]; msg[0] = 7 + dataLen; // message length, including length byte itself and checksum msg[1] = moduleIdentifier; msg[2] = msg_type; msg[3] = port; msg[4] = sensor_type; for(i = 0; i < dataLen; i++) { msg[5 + i] = data[i]; } msg[5 + dataLen] = xbee.frameID; xbee.frameID++; unsigned char checkSum = 0; // Calculate checkSum, attach to the end of each message so the receiving end can check integrity. To avoid message truncation and concatenation. for(i = 0; i < 6 + dataLen; i++) { checkSum += msg[i]; } msg[6 + dataLen] = 0xFF - checkSum; if(xbeePresent()) { while (P3IN & BIT1); // Wait till xbee is ready to take input delay_ms(10); // Wait 2 character's time: 1.7ms; RO = 3, 3 character time 2.5ms. Otherwise two adjacent messages will be combined into one RF package. 4ms is not enough for (i = 0; i < 7 + dataLen; i++) { xbeeSendByte(msg[i]); } } }
On the receiving end, software on PC will unpack the message, insert into a SQLite database.
Occasionally, the value of the hard coded variable in System A will appear differently on system B when received. Specifically, BIT7 of the value will be flipped from 1 to 0 or 0 to 1. For example, 0x0172 will show up in the database on B as 0x01F2, 0x0078 --> 0x00F8, 0x0190 --> 0x0110, 0x1388 --> 0x130B.
The message count and checksum of message appear to be correct on receiving end. So the the it is unlikely the change value occurred during transmission to UART and via Xbee radio. that leaves the only possible step to when the value of the hard coded variable is passed to tempArray before being packed into a message. But I find this hard to believe.
We have a few hundred System A deployed in field. So far only 1 particular A generated enough errors that caught our attention. In a controlled test setup, the error rate of this particular A is about 1 in every 250 messages. On other System A with the same PCB and test code and shared System B, the error rate is less than 1 in 40000. We detected only 1 error in two weeks.
This seems quite puzzling so far. Could anyone provide some pointers? Many thanks in advance.