A UART receive is truncated

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

A UART receive is truncated

Jump to solution
1,158 Views
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 Kudos
Reply
1 Solution
1,141 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi john71,

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

Best Regards,
Robin

View solution in original post

0 Kudos
Reply
1 Reply
1,142 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi john71,

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

Best Regards,
Robin

0 Kudos
Reply