Why are the last few bytes in UART0's TX buffer delayed?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why are the last few bytes in UART0's TX buffer delayed?

Jump to solution
1,248 Views
asfarley
Contributor IV

I'm printing out some strings over UART0 (the LPUART, I believe) on a K22F. 

Sometimes it works just fine; the entire string is printed out on the serial port. 

Other times, I see a strange behavior: most of the string is printed, except for the last few bytes. The next time a string is printed, the missing bytes appear, but the end of the next string is missing. 

For example, I print "Hello World!" and see:
"Hello Wor"

then, I trigger the next string ("another string") to be printed in my code, and I see:

ld!

another str

So it's like the UART is "falling a few bytes behind" and not catching up, even though the bytes are still in the TX buffer. 

I'm using the PE asynchronous serial component as a driver. Any ideas about why this is happening?

Labels (1)
0 Kudos
Reply
1 Solution
1,133 Views
mjbcswitzerland
Specialist V

Hi Alexander

You will have a problem with the buffer driver and not the (LP)UART. It will stop supplying the UART interrupt with the next byte to send at some point when it shouldn't and then the last bytes from the buffer - plus the next string - are sent the next time it is started.

Try the uTasker project (it is free on Git Hub and has a fool proof (LP)UART implementation in interrupt and DMA driven modes, including complete UART simulation). You can also use it as reference to solve the problem that you have.

Regards

Mark


Complete Kinetis solutions, training and support:http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

UART:
VLPS with continuous UART operation: https://community.nxp.com/message/421247#421247
UART: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

Modbus ASCII/RTU: http://www.utasker.com/docs/MODBUS/uTasker_MODBUS.PDF

View solution in original post

2 Replies
1,134 Views
mjbcswitzerland
Specialist V

Hi Alexander

You will have a problem with the buffer driver and not the (LP)UART. It will stop supplying the UART interrupt with the next byte to send at some point when it shouldn't and then the last bytes from the buffer - plus the next string - are sent the next time it is started.

Try the uTasker project (it is free on Git Hub and has a fool proof (LP)UART implementation in interrupt and DMA driven modes, including complete UART simulation). You can also use it as reference to solve the problem that you have.

Regards

Mark


Complete Kinetis solutions, training and support:http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html

UART:
VLPS with continuous UART operation: https://community.nxp.com/message/421247#421247
UART: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

Modbus ASCII/RTU: http://www.utasker.com/docs/MODBUS/uTasker_MODBUS.PDF

1,133 Views
asfarley
Contributor IV

Thank you very much.

0 Kudos
Reply