cancel
Showing results for 
Search instead for 
Did you mean: 

Question regarding ADC and DMA tranfer.

matic
Associate III
Posted on August 31, 2015 at 15:38

Hi.

I make 4 ADCs on ADC1 and other 4 on ADC2. I'm using DUAL mode, so the results are transferred in 32-bit word (one half for ADC1 and another half for ADC2). Thus I need 4 conversion times for all 8 conversions. The destination address for DMA is an array of 8 16-bit words and it works. Let's call this as one sequence.

Now, I would like to make more than one sequence with single trigger for AD start. Let say, I would like to make 10 sequences (for 80 conversions), which would take time equal to 40 conversions (because of DUAL mode).

If I am correct, I should define a destination array for DMA as 80 16-bit words and set the number of DMA tranfers to 40 (40 times of 32-bit).

ADC should be configured in SCAN mode as well. But now, I am not sure how should be ''number of conversions'' configured? As I said, I have 4 channels on each ADC and each ADC should go 10 times over the same channel (for ADC1: CH0 - CH1 - CH2 - CH3 - CH0 - CH1 - CH2 - CH3 - CH0 - ... 10x like this). And same for ADC2.

Would this work if I set number of conv. to 4 (for both ADCs), and DMA transfers to 40? Would ADC go throug all 40 (10x 4) conversions automatically?

Thanks 

#adc #dma
5 REPLIES 5
Posted on August 31, 2015 at 16:53

Well I'm not sure you can trigger multiple sets of samples. Basically in non-continuous mode it's going to do your 4x2 samples every time it gets a trigger.

You could try continuous mode, but problem is that it might not stop. You could try using a trigger, and experiment.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
matic
Associate III
Posted on August 31, 2015 at 17:21

Is possible to start  AD in CONTINUOUS mode by software at certain moment and then also

interrupt

(finish) AD conversions when you want? If that is possible, then I would start AD in continuous mode when I want and wait for TCIF (transfer complete) flag for DMA. This would be configured to 40 transfers. Then in ISR I would stop ADC.

Posted on August 31, 2015 at 18:33

You'd have to do what I do, experiment.

You can limit the sampling with the DMA TC, with the DMA in Normal mode. The problem that I see is getting the ADC reinitialized, because when the DMA stops servicing the ADC will over-run. Restarting it, and resynchronizing the scan, might take some effort.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mauro2399
Associate II
Posted on September 01, 2015 at 12:35

I agree with clive1, the cleanest way is having the ADC run continuously looping on a sequence of 4 conversions, and let the DMA stop it (by overrun) when the buffer is full, then fire an IRQ and reset the DMA and ADC units.

matic
Associate III
Posted on September 01, 2015 at 21:00

I am not sure if I understand right. When all DMA transfers will be carried out, program goes to DMA IRQ_Handler (because of transfer complete interrupt enable). At that point, overrun flag should be set automatically? But why should I look for that flag at all? Is not enough that, when TCIF is set, I know the buffer is full (all conversions are done) and I just stop ADC and reset it?