PDB continuous mode, 2 ADCs in parallel, DMA linking & scatter/gather

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

PDB continuous mode, 2 ADCs in parallel, DMA linking & scatter/gather

1,471 Views
yannickjeantet
Contributor I

Hello,

I am learning to use a MK66FX1M0VMD18 (teensy 3.6).

My goal is to record datas from 8 analog inputs converted with the ADC0 and ADC1.

I read the "K66 Sub-Family Reference Manual".

Now I wonder if the following idea  is possible :

The  PDB  would be in continuous mode and its two channels 0/1 would trigger in parallel :

  -  ADC_0_A     which thanks to the back to back mecanic, would trigger ADC_0_B

  -  ADC_1_A               "                                      "                              "          ADC_1_B

At this point I would dispose of a set of four results in ( RA0 RB0 RA1 RB1) that I could  transfer with DMA,  in a circular buffer...

This  DMA transfere would be triggered , for exemple, by the end of conversion of ADC_1_B.

This DMA would it turn trigger through the "link" mecanism, another dma channel which would copy in the right registers of the ADCs (ADCx_SC1n),   the adresses (ADCH)  of four new data sources.    Lastly using " scatter/gather "  the TCD of this last DMA channel would be updated in order to toggle between analog inputs 1..4 and 5..8.

And so on . . .

Theoretically  it seems possible... but there are probably so many pitfalls to avoid, that I wish to get your advices and warning,  before diving in...

Sorry for my bad english.

Yannick.

Labels (1)
0 Kudos
3 Replies

725 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, yannick,

I think your idea is possible. But why do you use DMA to transfer samples from ADC registe to memory and transfer ADC channels from memory to ADC_SC1x registers? it is complicated. If the core workload is not big, i suggest you use ADC interrupt, in the ADC ISR, you can read the two ADC samples to memory , then write the ADC_SC1x registers, it is simple.

BTW, it is okay to set the PDB in contionuous mode, which means that the PDB counts tick from 0 to PDB_MOD repeatedly. You can set the PDB0_CH0DLY0 to set the instant to trigger ADC_0_A, set the PDB0_CH0DLY1 to set the instant to trigger ADC_0_B.  You can set the PDB0_CH1DLY0 to set the instant to trigger ADC_1_A, set the PDB0_CH1DLY1 to set the instant to trigger ADC_1_B, in this way, you can use Ping-pong mode to sample two channels for each ADC converter, of course, this is not backtoback mode of PDB.

If you use DMA,  for each ADC converter, when the ADC_x_B conversion is over, you can trigger DMA, the DMA can transfer two samples from ADC_x_RA and ADC_x_RB to memory, you can use minor link of DMA, which can transfer ADC channels data in memory to ADC_x_SC1A and ADC_x_SC1B.

Hope it can help you

BR

Xiangjun Rong

0 Kudos

725 Views
yannickjeantet
Contributor I

Hello Xiangiun Rong,

Thank's for your reply.

1) One told me that it is a typical case where we "must" use DMA.

2) I am discovering DMA, I find this small "machine",  very clever and pleasant to use. Mainly PDB triggering, Scatter/Gather and channel linking, which give so many possibilities...

3) Moreover the sampling rate should be rather high, 32k samples/S per channel. Thus the idea that the MCU  remains free, makes me feel better.

This said a lot of people tells me that it does not work as what we believe, in some cases...  And when you discover it becomes difficult to understand if the probleme comes from the code or from the hard.

That is why I expect from experts of this forum, to know if it exists some (uncommented) cases which should work for a new innocent user but dont work for obvious but not trivial reasons...

Sincerely,Yannick.

De : xiangjun.rong <admin@community.nxp.com>

À : yannick jeantet <mice.recorder@yahoo.fr>

Envoyé le : Lundi 18 décembre 2017 4h35

Objet : Re: - Re: PDB continuous mode, 2 ADCs in parallel, DMA linking & scatter/gather

#yiv2650043635 * #yiv2650043635 a #yiv2650043635 body {font-family:Helvetica, Arial, sans-serif;}#yiv2650043635 #yiv2650043635 h1, #yiv2650043635 h2, #yiv2650043635 h3, #yiv2650043635 h4, #yiv2650043635 h5, #yiv2650043635 h6, #yiv2650043635 p, #yiv2650043635 hr {}#yiv2650043635 .yiv2650043635button td {}

|

NXP Community

|

Re: PDB continuous mode, 2 ADCs in parallel, DMA linking & scatter/gather

reply from xiangjun.rong in Kinetis Microcontrollers - View the full discussionHi, yannick,I think your idea is possible. But why do you use DMA to transfer samples from ADC registe to memory and transfer ADC channels from memory to ADC_SC1x registers? it is complicated. If the core workload is not big, i suggest you use ADC interrupt, in the ADC ISR, you can read the two ADC samples to memory , then write the ADC_SC1x registers, it is simple.BTW, it is okay to set the PDB in contionuous mode, which means that the PDB counts tick from 0 to PDB_MOD repeatedly. You can set the PDB0_CH0DLY0 to set the instant to trigger ADC_0_A, set the PDB0_CH0DLY1 to set the instant to trigger ADC_0_B.  You can set the PDB0_CH1DLY0 to set the instant to trigger ADC_1_A, set the PDB0_CH1DLY1 to set the instant to trigger ADC_1_B, in this way, you can use Ping-pong mode to sample two channels for each ADC converter, of course, this is not backtoback mode of PDB.If you use DMA,  for each ADC converter, when the ADC_x_B conversion is over, you can trigger DMA, the DMA can transfer two samples from ADC_x_RA and ADC_x_RB to memory, you can use minor link of DMA, which can transfer ADC channels data in memory to ADC_x_SC1A and ADC_x_SC1B.Hope it can help youBRXiangjun Rong

Reply to this message by replying to this email, or go to the message on NXP Community

Start a new discussion in Kinetis Microcontrollers by email or at NXP Community

Following Re: PDB continuous mode, 2 ADCs in parallel, DMA linking & scatter/gather in these streams: Inbox

This email was sent by NXP Community because you are a registered user.

You may unsubscribe instantly from NXP Community, or adjust email frequency in your email preferences |

|

0 Kudos

725 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi yannick jeantet

Please check the following doc:

https://community.nxp.com/docs/DOC-335320 

I think it could help you, it uses only one ADC, but It should be easy to implement the other ADC.

Regards

Jorge Alcala

0 Kudos