(LP)UART Error Flags

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

(LP)UART Error Flags

913 次查看
overdamped
Contributor II

Hello,

 

I was wondering what the recommended way of receiving with errors in the KSDK uart driver is? I've found that inserting the following into the DMA receive interrupt (and something similar into the first conditional of the receive interrupt driven approach) fix issues I'm having. This strategy was essentially pulled from legacy processor expert's generated code, but I'm not sure if this is the correct way to accomplish this? Has anyone else run into this problem?

 

if (LPUART_HAL_GetStatusFlag(base, kLpuartNoiseDetect) ||      LPUART_HAL_GetStatusFlag(base, kLpuartParityErr) ||      LPUART_HAL_GetStatusFlag(base, kLpuartFrameErr) ||      LPUART_HAL_GetStatusFlag(base, kLpuartRxOverrun)) {      LPUART_HAL_ClearStatusFlag(base, kLpuartNoiseDetect);      LPUART_HAL_ClearStatusFlag(base, kLpuartParityErr);      LPUART_HAL_ClearStatusFlag(base, kLpuartFrameErr);      LPUART_HAL_ClearStatusFlag(base, kLpuartRxOverrun);      LPUART_HAL_Getchar(base, &placeholderChar);      LPUART_HAL_ClearStatusFlag(base, kLpuartRxDataRegFull); }  
标签 (1)
0 项奖励
2 回复数

517 次查看
isaacavila
NXP Employee
NXP Employee

Hi Overdamped,

I don't know what it the issue you are facing with but actually, it is the right way to poll for every LPUART's flag using KSDK API functions.

Also, if you are using interrupts, you can enable/disable different flags to produce an interrupt whether next cases occur:

Enumerator
kLpuartIntLinBreakDetect

LIN break detect.

kLpuartIntRxActiveEdge

RX Active Edge.

kLpuartIntTxDataRegEmpty

Transmit data register empty.

kLpuartIntTxComplete

Transmission complete.

kLpuartIntRxDataRegFull

Receiver data register full.

kLpuartIntIdleLine

Idle line.

kLpuartIntRxOverrun

Receiver Overrun.

kLpuartIntNoiseErrFlag

Noise error flag.

kLpuartIntFrameErrFlag

Framing error flag.

kLpuartIntParityErrFlag

Parity error flag.

So you must check which flag/event caused the interrupt request.

Also, you can notify to your application (by returning an error code) that error has occurred instead of just clearing its corresponding flag.

Regards,

Isaac

0 项奖励

517 次查看
overdamped
Contributor II

Thanks. The problem was that the legacy processor expert would automatically clear flags within the interrupt upon errors. Therefore if I called receive with an OSA_WAIT_FOREVER timeout, it would effectively lock up receive on the peripheral. The solution was to move towards an acceptable timeout value and then clear error flags upon timeout within the calling thread.

0 项奖励