Hello,
I need to implement a ring buffer for receiving from UART via DMA. For consistency, I'd like to keep using the SDK.
What I want is to set up UART and DMA once, and have a circular buffer that overwrites itself over and over, completely unattended (I can't miss a character, ISR to switch buffer would be too slow). I'll have a periodic task reading from the ring buffer.
The thing is, I just cannot figure out how to do it. The most obvious way I've tried breaks the SDK's abstraction, making it (very) leaky, and also doesn't work:
Looking into edma_driver.h, there is this function EDMA_DRV_ConfigLoopTransfer() which looked to akin to EDMA_DRV_ConfigMultiBlockTransfer() that the UART driver uses. I could find a Freescale document recommending it, but the SDK back there seemed different back then and it tells me to call EDMA_DRV_RequestChannel() beforehand, which is not available anymore: https://www.nxp.com/docs/en/supporting-information/Enhanced-Direct-Memory-Access-Controller-Training...
I tried:
- commenting out the parts of the UART driver that stopped the DMA, that just made the DMA write outside the buffer's limit.
- making my own function to activate DMA and UART's DMA requests using EDMA_DRV_ConfigLoopTransfer (InitUartDmaReceive()), that leads to DefaultISR on the first char.
So, is there a sensible way to do it? Or is the SDK really just lacking and I have to fiddle with registers?
Attached, a test project of mine. #define DMA_LOOP turns on the looping attempt. Using S32K148EVB-Q176.
Best regards,