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
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.
已解决! 转到解答。