How to configure multi-channel ADC with DMA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to configure multi-channel ADC with DMA

3,679 Views
ryanramanathan
Contributor I

I have a FRDM-K64 evaluation board.

I am developing using KSDK.

I am trying to setup 4 ADC channels each at 50Ksps using EDMA:

    ADC0 Channels:  0 & 1

    ADC1 Channels: 0 & 1

I have setup PDB trigger channels and they are working without the DMA.

Also I got ADC0 channel0 and ADC1 channel0 to work with DMA.

 

Now I am trying to get flexible scan mode to work so that both ADC0 channels can be dumped into the memory buffer using DMA.

How do I setup the elink DMA channel to trigger and toggle between ADC0 channel0 and 1?  (Using KSDK)

-  I have DMA channel 1 (ADC conversion --> Memory)

-  DMA channel 0 the elinked channel to set ADC0_SC1A toggling between kAdc16Chn0 & kAdc16Chn1

-  DMA channel 1 is setup to ping pong between two buffers so that when one is being written to, the other buffer can be transferred to SD Card/ USB memory.

- PDB is setup to have a single channel group pre trigger

 

Also can't I use PDB0 soft interrupt to trigger DMA channel 0 (ADC0_SC1A)  instead of elink? 

I have tried using EDMA_DRV_ConfigLoopTransfer and EDMA_HAL_HTCDSetChannelMinorLink.

You can find incomplete code attached.

 

Thanks

Original Attachment has been moved to: adcDMAc.zip

0 Kudos
2 Replies

1,636 Views
alejandra_guzman
NXP Employee
NXP Employee

  I think that this document Using DMA to Emulate ADC Flexible Scan Mode with KSDK  contains the software you are looking for.

0 Kudos

1,636 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Ryan,

Why not using PDB0's ping pond mode to trigger ADC0 CH0 and ADC0 CH1? You may set up the eDMA as a major loop with 2 minor loops, in the first minor loop, DMA moves the result of ADC0 CH0, and in the second minor loop, DMA moves the result of ADC0 CH1, and when the major loop completes, you may switch the buffer in the ISR of eDMA, The PDB0 can be trigger by SW or RTC and something like that.

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos