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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,063 次查看
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?

标签 (1)
0 项奖励
回复
1 解答
948 次查看
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

在原帖中查看解决方案

2 回复数
949 次查看
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

948 次查看
asfarley
Contributor IV

Thank you very much.

0 项奖励
回复