USART interrupt handler, handle Rx timeout#38
Conversation
|
@ek-ap , thank you for reporting the issue and providing the fix. We will review it. Meanwhile, did you try using the Ring buffer mode of UART PLIB? Based on your description, it seems you are receiving variable length messages and the ring buffer mode is better suited for such requirements. You can find an example application here. |
|
Yes I did. Unfortunately, the Ring buffer mode does not provide DMA transfer out-of-the-box. All data transfer seems to go through the processor. As we're receiving data at 2 MBaud (not a typo) on one USART interface (and also want to use the processor for other tasks), we rely on DMA data transfer. I would love to see the DMA transfer feature on the PLIB ring buffer off-the-shelf, but meanwhile the above patch will do. We've found a way to configure the DMA linked-list mode to act similar to a ring buffer. But we need to flush the DMA data transfer after receiving of a full message (i.e. upon Rx timeout). So we need to be able to catch the USART Rx timeout interrupt. |
cf63435 to
f522e1e
Compare
…ons for receiver timeout handling
|
How is the status of this request? In the mean time we added cache invalidation code to the MCAN peripheral lib to make it work wit data-cache enabled. Since MCVN uses DMA for the transfers to/from the message RAM, data is corrupted if cache is not cleared/invalidated correctly. |
|
How is the status of this request? Since the change of harmony content inclusion in MPLAB X IDE 6.3 it is quite combersome to get our custom content into the MCC. Still our system depends on these additions. |
On an
ATSAME70N19B, the Harmony 3 USART interrupt handlerUSARTx_InterruptHandler( void )currently discards theTIMEOUTinterrupt that is generated when the timeout delay period (US_RTOR.TO) expires. Commit acc4c82 therefore adds a hook to the interrupt handler to process the Rx timeout interrupt. I would strongly ask for such a hook (as in the commit or similar) to be included in the next release, as it helps when receiving variable-length messages.It could also make sense to enable/disable the timeout feature via the Harmony 3 Configuration interface. I'm unfortunately not familiar with how to include such options in the GUI. A similar hook could be implemented for the transmitter timeguard register (
US_TTGR), and also for the LIN mode. As I only work with the standard USART mode, these are not included in the patches below.Additionally, commit f692803 contains user interface functions to set/enable, reset, and clear/disable the Rx timeout for the standard USART interface. These are not as urgently needed as the hook in acc4c82, but it would also be nice to have such an interface.