LPUART problem

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

LPUART problem

3,317件の閲覧回数
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?

ラベル(1)
タグ(1)
0 件の賞賛
返信
2 返答(返信)

2,621件の閲覧回数
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 件の賞賛
返信

2,621件の閲覧回数
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