A UART receive is truncated

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

A UART receive is truncated

跳至解决方案
1,501 次查看
john71
Senior Contributor I

 I work with MKV58F24. When I send a buffer from PC - 128 bytes - I get only 9 on a micro controller side.

I tried a polling method

 

 

 

 

void UART_RecvPacket()
{
	unsigned char chr;

	/* If new data arrived. */
	if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART0))
	{
		chr = UART0->D;
		rx_idx++;
		printf("IDX = %d\n", (int)rx_idx);
	}
}

 

 

 

 

As well as an interrupt method

 

 

 

 

void UART0_RX_TX_IRQHandler(void)
{
unsigned char chr;

	/* If new data arrived. */
	if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & UART_GetStatusFlags(UART0))
	{
		chr = UART0->D;
		rx_idx++;
		printf("IDX = %d\n", (int)rx_idx);
	}
}

 

 

 

 

 

The same result - only 9 bytes from 128 are received.

After receiving 9 bytes a status register does not indicates any problem

uart_sr.png

Set lower baud rate - 9600 (was 115200) - getting a bit more - 17 bytes.

What can be a problem?

 

OMG. I found the problem - for a debug purpose I used printf a lot in the code. It really slows down and stucks the program flow.

0 项奖励
回复
1 解答
1,484 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi john71,

Looks like you've found the root cause.
Thanks for sharing.

Best Regards,
Robin

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,485 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi john71,

Looks like you've found the root cause.
Thanks for sharing.

Best Regards,
Robin

0 项奖励
回复