Hello. I'm trying to transmit some serial data from within an ISR. My issue is that when I send, say an array of a dozen or two dozen bytes, what comes out the serial port, as measured by a logic analyzer, is not quite the same as what I'm sending. Differences occur at the 7th byte and then every 2-4 bytes after that. For example, if I send
Out comes:
Here is my code:
This feels similar to what serial1.c is doing when sending bytes. Can anyone spot anything I'm doing wrong?
Code:
01 02 03 04 05 06 18 08
Code:
01 02 03 04 05 06 04 08
Here is my code:
Code:
void uart0_tx(const uint8_t *b, int len) {
if (len <= 0) {
return;
}
// Enable transmission
UART0_C2 = UART_C2_TE;
while (len > 0) {
// Wait for space to be available
while ((UART0_S1 & UART_S1_TDRE) == 0) ;
#ifdef HAS_KINETISK_UART0_FIFO
do {
UART0_D = *(b++);
len--;
} while (len > 0 && UART0_TCFIFO < 8);
#else
UART0_D = *(b++);
len--;
#endif // HAS_KINETISK_UART0_FIFO
}
// Wait for transmission complete
while ((UART0_S1 & UART_S1_TC) == 0);
// Disable transmission
UART0_C2 &= ~UART_C2_TE;
}
This feels similar to what serial1.c is doing when sending bytes. Can anyone spot anything I'm doing wrong?