UART Ring Buffer with DMA using SDK

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

UART Ring Buffer with DMA using SDK

ソリューションへジャンプ
1,932件の閲覧回数
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 件の賞賛
返信
1 解決策
1,902件の閲覧回数
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 件の賞賛
返信
1 返信
1,903件の閲覧回数
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 件の賞賛
返信