UART Ring Buffer with DMA using SDK

cancel
Showing results for 
Search instead for 
Did you mean: 

UART Ring Buffer with DMA using SDK

Jump to solution
257 Views
thosewhowish2b
Contributor II

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,

0 Kudos
1 Solution
227 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Wesley,

the SDK does not cover 100% functionality of the microcontroller. The DMA module itself allows us to handle almost all operations and situations we can think about. However, the UART driver does not cover this use-case. As we do not support modifications of SDK code, this should be implemented rather by your own code.

Regards,

Lukas

View solution in original post

0 Kudos
1 Reply
228 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Wesley,

the SDK does not cover 100% functionality of the microcontroller. The DMA module itself allows us to handle almost all operations and situations we can think about. However, the UART driver does not cover this use-case. As we do not support modifications of SDK code, this should be implemented rather by your own code.

Regards,

Lukas

0 Kudos