Hello,
I am trying to send bytes of data over UART from an MSP430F5529. The UART transmission is being done inside of the ADC12ISR. Our transmission should be 7 byte packets with bytes 3-6 being data from an ADC. One of these ADC data bytes, which is sent by the sendWeight function, is sometimes dropped. The first two bytes and the last byte are always sent successfully. It seems like the issue is somehow timing related, as the transmissions are always successful when the code is executed with breakpoints when each bytes is transmitted. We disable the ADC12 interrupt inside the ADC12ISR to avoid the interrupt being triggered while the ISR is running. Additionally, the last byte is always transmitted even though one of the intermediate ADC data bytes was not transmitted successfully.
Is there any reason why certain bytes of a UART transmission wouldn't be sent?
The relevant portion of our code is below.
Any help would be greatly appreciated. Thank you.
// send A6 info through UART // 1. position 2 UCA1TXBUF = pos2; while(UCA1STAT&UCBUSY); // 2. add vs remove UCA1TXBUF = add; while(UCA1STAT&UCBUSY); // 3. weight newWeight = getFinalWeight(TIMES); sendWeight(newWeight - preWeight); preWeight = newWeight; UCA1TXBUF = 0x0A; //New line while(UCA1STAT&UCBUSY);
// Send weight data using UART void sendWeight(float input) { unsigned long dwResult = F2DW(input); // c[]: Store float number into separate bytes // c[0] highest byte, transmitted first // c[3] lowest byte, transmitted last // c[4] = \0, mark the end, not transmitted c[3] = (dwResult & 0xFF); // lowest byte c[2] = ((dwResult >> 8) & 0xFF); c[1] = ((dwResult >> 16) & 0xFF); c[0] = ((dwResult >> 24) & 0xFF); // highest byte c[4] = '\0'; uint8_t i = 0; for (i = 0; i < 4; i++) { UCA1TXBUF = c[i]; while(UCA1STAT&UCBUSY); } }
The first two bytes are always sent successfully, however one of the next