ADC channel change while using PDB trigger and DMA?

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

ADC channel change while using PDB trigger and DMA?

1,070 Views
marcohess
Contributor II

I have a system with a K22 where I use ADC0 with two channels using the A and B triggers.

The A & B channels are triggered by the PDB which also triggers a DAC and at the end of the PDB cycle, it triggers 2 DMA channels to transfer the ADC0 A & B results, with each DMA cycle collecting 256 samples in a ping-pong buffer fashion.

After 10 or so of such cycles, I now need to switch the ADC channels to two different ones.

I tried calling ADC_DRV_ConfigConvChn to change the channels while the PDB and DMA keep going, but it seems that the ADC output 'locks up'.

What are the required steps to change the channel on the ADC while it is being triggered by the PDB?

Is disabling the ADC trigger in the PDB enough?

0 Kudos
2 Replies

530 Views
mjbcswitzerland
Specialist V

Hi Marco

When changing the ADC channels you need to disable the PDB triggering because there is otherwiese a high chance of an error occuring, which if flagged in the PDB (due to ADC output overrun or similar). The operation then stops. Although it is supposed to be possible to clear the error flag and continue I have never heard of anyone actually being able to do this successfully (I also tried in vain) so effectively it results in a dead-lock requiring a complete re-initialisation.

As long as the error can't occur (with DMA you have no risk of ADC output overrun in normal circumstance) and the ADC channel is not changed during conversions it will run forever.

In two products that I have been involved with in which a similar configuration is used the workaround was to disable the PDB - ensure that any ADC conversions presently in progress are allowed to complete - then do the channel change (or whatever else could be sensitive) - then re-enable the PDB. Allowing the PDB to continue running but disabling ADC triggers may also be equivalent. Avoiding an ADC conversion error is what must be achieved at all costs!

Regards

Mark

Kinetis: µTasker Kinetis support

K22: µTasker Kinetis FRDM-K22F support / µTasker Kinetis TWR-K22F120M support

For the complete "out-of-the-box" Kinetis experience and faster time to market

530 Views
marcohess
Contributor II

Thanks Mark,

Looks like I am halfway then. I got the PDB ADC trigger disabled, change the channel and then reenable the PCB ADC trigger.

That seems to work, but I take your advise and will insert a check that the current conversion is complete before changing the channel.

Cheers,

Marco

0 Kudos