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); }
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:
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
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.