A UART receive is truncated

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

A UART receive is truncated

ソリューションへジャンプ
1,159件の閲覧回数
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,142件の閲覧回数
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,143件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi john71,

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

Best Regards,
Robin

0 件の賞賛
返信