Kevyn Schwab

KL15Z UART buffer "stutter"

Discussion created by Kevyn Schwab on Jun 15, 2016

EDIT: After retrying different UART channels and un-commenting the code


My program is now working. There must have been an error in the generated code or init configuration that was reset after I flipped channels.

I'm experiencing some bizarre behavior from my KL15 microcontroller. When attempting to send 6 bytes continuously, my UART channel instead sends 2 bytes before stalling, or stuttering, before sending the next consecutive byte and then immediately restarting from the beginning of the message sequence. Oddly, the UART waits until the sending function is again called (once every second through a routine in the main RTOS structure) before sending the byte that I had previously instructed it to send, although by that time a new byte should have been loaded into the buffer. Here is a Saleae analysis of the problem:

Note how the blips on the top image are each two bytes, spaced about one second apart. The middle image is the first two bytes, and the bottom image, the last two. The message that I am trying to send is:

     0x53     0x04     0x11     0x11     0x00     0x03

Which should be repeating every second. Instead, as you can see, the first message begins to transmit the first two bytes correctly, but then is cut short. The next subsequent byte inexplicably winds up being sent a second later.


The code is very simple, passing an array with 6 members to a for loop:


for(uint8_t i=0;i<6;i++){


//        while(uart_GetCharsInTxBuf()!=0); // Doesn't improve the problem



I can confirm that this code works by stepping through each loop individually, which interestingly does send out each byte in order. This leads me to believe that it must be a problem with the UART component - but what, I simply cannot figure out!


Any suggestions on how to proceed debugging this would be greatly appreciated. In interest of full disclosure, I have confirmed that the physical UART channel (UART0 on the KL15) which I am using is functioning correctly by routing a different UART component through UART0, transmitting to a serial port and confirming the message received on my terminal application. I have also tried switching to another UART channel to no avail.


Thank you for reading this lengthy post!