EDMA example code for ADC to buffer transfer using KSDK API calls?

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

EDMA example code for ADC to buffer transfer using KSDK API calls?

3,098 Views
marcohess
Contributor II

I am pretty new to the KDSK and the EDMA peripheral and its concepts on how it fits all together. It's a pretty steep learning curve.

 

What I need is:

  • Run both ADC0 and ADC1 in the K22 in parallel to sample two channels simultaneously at around 100kHz rate.
  • Transfer the ADC0 and ADC1 results to memory in blocks of 1024 samples for each ADC.
  • After a transfer to say buffers A0 and A1, flip to new buffers B0 and B1 and after that back to A0 and A1.
  • After each DMA block I need an interrupt that tells me which buffer has the latest data so I can process the data in the buffer (quadrature multiply into I & Q data, and FIR filter and decimate the I & Q).

 

I have the ADC's running with interrupts and triggered by the PDB on a slower rate, but now I need to get the ADC triggering the DMA and transfer into buffers.

 

So how do I set that up?  I am a bit lost in the KSDK API functions. The describe very well what all the parameters are but not in which order they need to be setup and how it all fits together.

 

So far I think I have a handle on:

  • EDMA_DRV_Init
  • EDMA_DRV_RequestChannel
  • EDMA_DRV_InstallCallback
  • EDMA_DRV_StartChannel

 

But how do I setup these transfer descriptors and links to do what I want?

 

Anybody can provide a few lines of a sample code or a pointer to sample code on how to do this using the KSDK API functions?

Labels (1)
Tags (4)
5 Replies

1,481 Views
mauricelauze
Contributor III

Hi Marco,

I am stuck with the same problem as yours !

Have you found something about that ?

Do you have any project example available ?

Thank you,

Maurice

0 Kudos

1,481 Views
marcohess
Contributor II

Attached a bit of code extracted from my project that should put you on your way.

In the ADC it still seems to enable the callbacks, but that was mainly there for debug

to see if the ADC was firing. With the EDMA running that can be removed.

Good luck. It was a steep ride for me too.

Marco

0 Kudos

1,481 Views
mauricelauze
Contributor III

Hello Marco,

Thank you very much for sharing this !

It looks that you haven't use Processor Expert to generate the code for ADC using DMA, is that right ?

I have investigated into the components of Processor Expert for KDS and it makes me confusing about the use of it...

First, there are Init_ADC and fsl_adc components for the ADC. One should use fsl_adc to get the code for callback and trigger mode.

But fsl_adc is too simple to init properly the ADC... Init_ADC is suitable for this, but it is not possible to join Init_ADC and fsl_adc together (they share the same peripheral and an issue is generated by PE).

It is like the Processor Expert version for KDS is not finished yet. PE for CodeWarrior is much more advanced... It is possible to set all the parameters in LDD_ADC.

Anyway, I have to go on with my project using KDS and I will write "by hands" the necessary code for the ADC transfert involving DMA.

It is a pity to spend time for this ! And there is no code example for that, and no documentation too...

Thanks again Marco.

Maurice

0 Kudos

1,481 Views
trytohelp
NXP Employee
NXP Employee

Hi Marco,

Several demo examples are delivered in the KSDK.

There are examples for ADC, eDMA, GPIO, etc ...

Please have a look under \KSDK_1.0.0\demos installation folder.

For documentation , please have a look to:

    \KSDK_1.0.0\doc\Kinetis SDK Demo Applications User's Guide.pdf

    \KSDK_1.0.0\doc\Kinetis SDK API Reference Manual.pdf

Have a great day,
Pascal Irrle

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

0 Kudos

1,481 Views
mauricelauze
Contributor III

Hi Pascal,

Looking at the \KDS_1.1.1 and \KSDK_1.0.0, I see no examples involving an ADC and DMA transfert with Processor Expert components...

I don't see clearly if I have to use fsl_adc and fsl_edma or just the INIT_ADC and INIT_eDMA...

What about the PDB component since Dma request is set for ADC and DMA ? Is it necessary to instance a PDB component ?

An exemple would be MUCH appreciated since I haven't found any document about the use of Processor Expert for KDS.

Thank you,

Maurice

0 Kudos