MCXA156VLL ADC mulit channel read with DMA

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

MCXA156VLL ADC mulit channel read with DMA

Jump to solution
398 Views
yaowei
Contributor I

Hi,

I am using the FRDMMCXA156 board and referring to the SDK (25.09.00) example lpadc_edma.
 
The example only shows how to read one ADC channel using LPTMR and DMA.
 
However, I need to read 7 ADC channels, and the trigger ID only 0 to 3. How can I perform multi-channel ADC read with DMA?
Labels (2)
Tags (2)
0 Kudos
Reply
1 Solution
361 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @yaowei 

You can use a single trigger source to collect multiple channels.

You can concatenate multiple sampling commands under a trigger source, allowing the ADC to automatically sample 7 channels in sequence after triggering.

The chainedNextCommandNumber field allows the ADC to automatically execute the next command after completing a sample.

BR

Harry

View solution in original post

0 Kudos
Reply
2 Replies
296 Views
yaowei
Contributor I

Hi @Harry_Zhang

Thank you very much for your reply. I was able to achieve my goal using chainedNextCommandNumber, but I still have a few questions.

I'm using LPTIMER to trigger both ADC0 and ADC1, and I'm transferring the ADC data using DMA0 Channel 0 and Channel 1. The reason I use two DMA channels is because lpadcDmaChnlConfig.channelRequestSource can only be set to either kDma0RequestMuxAdc1FifoRequest or kDma0RequestMuxAdc0FifoRequest.

In this case, is it possible to use only one DMA channel to handle both ADCs?



Thanks

0 Kudos
Reply
362 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @yaowei 

You can use a single trigger source to collect multiple channels.

You can concatenate multiple sampling commands under a trigger source, allowing the ADC to automatically sample 7 channels in sequence after triggering.

The chainedNextCommandNumber field allows the ADC to automatically execute the next command after completing a sample.

BR

Harry

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2199636%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMCXA156VLL%20ADC%20mulit%20channel%20read%20with%20DMA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2199636%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%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3E%3CSPAN%3Eto%20%3C%2FSPAN%3E%3CSPAN%3Eread%20%3C%2FSPAN%3E%3CSPAN%3E7%20%3C%2FSPAN%3E%3CSPAN%3EADC%20%3C%2FSPAN%3E%3CSPAN%3Echannels%2C%20%3C%2FSPAN%3E%3CSPAN%3Eand%20%3C%2FSPAN%3E%3CSPAN%3Ethe%20%3C%2FSPAN%3E%3CSPAN%3Etrigger%20%3C%2FSPAN%3E%3CSPAN%3EID%20only%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E0%20%3C%2FSPAN%3E%3CSPAN%3Eto%20%3C%2FSPAN%3E%3CSPAN%3E3.%20%3C%2FSPAN%3E%3CSPAN%3EHow%20%3C%2FSPAN%3E%3CSPAN%3Ecan%20%3C%2FSPAN%3E%3CSPAN%3EI%20%3C%2FSPAN%3E%3CSPAN%3Eperform%20%3C%2FSPAN%3E%3CSPAN%3Emulti-%3C%2FSPAN%3E%3CSPAN%3Echannel%20%3C%2FSPAN%3E%3CSPAN%3EADC%20%3C%2FSPAN%3E%3CSPAN%3Eread%20%3C%2FSPAN%3E%3CSPAN%3Ewith%20%3C%2FSPAN%3E%3CSPAN%3EDMA%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2199636%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAnalog(ADC%7CCMP%7CDAC%7COpAmps)%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMCXA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2201611%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCXA156VLL%20ADC%20mulit%20channel%20read%20with%20DMA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2201611%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229957%22%20target%3D%22_blank%22%3E%40Harry_Zhang%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20for%20your%20reply.%20I%20was%20able%20to%20achieve%20my%20goal%20using%20%3CSTRONG%3EchainedNextCommandNumber%3C%2FSTRONG%3E%2C%20but%20I%20still%20have%20a%20few%20questions.%3C%2FP%3E%3CP%3EI'm%20using%20LPTIMER%20to%20trigger%20both%20ADC0%20and%20ADC1%2C%20and%20I'm%20transferring%20the%20ADC%20data%20using%20DMA0%20Channel%200%20and%20Channel%201.%20The%20reason%20I%20use%20two%20DMA%20channels%20is%20because%20%3CSTRONG%3ElpadcDmaChnlConfig%3C%2FSTRONG%3E.%3CSTRONG%3EchannelRequestSource%3C%2FSTRONG%3E%20can%20only%20be%20set%20to%20either%20%3CSTRONG%3EkDma0RequestMuxAdc1FifoRequest%3C%2FSTRONG%3E%20or%20%3CSTRONG%3EkDma0RequestMuxAdc0FifoRequest%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EIn%20this%20case%2C%20is%20it%20possible%20to%20use%20only%20one%20DMA%20channel%20to%20handle%20both%20ADCs%3F%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2199983%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MCXA156VLL%20ADC%20mulit%20channel%20read%20with%20DMA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2199983%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F256581%22%20target%3D%22_blank%22%3E%40yaowei%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20use%20a%20single%20trigger%20source%20to%20collect%20multiple%20channels.%3C%2FP%3E%0A%3CP%3EYou%20can%20concatenate%20multiple%20sampling%20commands%20under%20a%20trigger%20source%2C%20allowing%20the%20ADC%20to%20automatically%20sample%207%20channels%20in%20sequence%20after%20triggering.%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3EchainedNextCommandNumber%3C%2FSTRONG%3E%20field%20allows%20the%20ADC%20to%20automatically%20execute%20the%20next%20command%20after%20completing%20a%20sample.%3C%2FP%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EHarry%3C%2FP%3E%3C%2FLINGO-BODY%3E