LPUART problem

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

LPUART problem

2,113 Views
igormasár
Contributor II

Hello, my application uses LPUART, this part of application is based on your example UART. In initialisation part I use your function LPUART1_receive_char and that works correctly.I can send string from my computer to the board. In main cyclic part of my program I send some CAN messages and so on. Here I just want to check whether the computer sent some UART string. Here I cannot wait until some data are in UART. Hence I modified your function to this function:

char LPUART1_check_receive_char(void)

char recieve = '\0';

if((LPUART1->STAT & LPUART_STAT_RDRF_MASK)>>LPUART_STAT_RDRF_SHIFT == 1) {

recieve = LPUART1->DATA;}

return recieve;

}

It is working until I send just one character. If I send a string the UART stops working (but program is still working correctly except UART cannot receive any char (even though I send one character).

Could you help me?

Labels (1)
Tags (1)
0 Kudos
2 Replies

1,417 Views
igormasár
Contributor II

Thank you for your answer. Your answer partly helped. However I think the same what you wrote - using interrupt, DMA and maybe also FIFO. But I do not have knowledge how to do it. Could you provide simple example (without any SDK)  - Reading UART with DMA, interrupt, eventually FIFO ? Thank you in advance.

0 Kudos

1,417 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Igor,

most probably the Overrun flag is set. While the OR flag is set, no additional data is stored in the data buffer even if sufficient room exists. To clear OR, write logic 1 to the OR flag.

Try to add checking of OR in your function and clear it if set.

But it would be better to use the interrupt or DMA to read receive bytes, especially if string is received and your SW polling is not fast enough.

BR, Petr