cancel
Showing results for 
Search instead for 
Did you mean: 

DMA of continuous mode ADC triggered by event out of Timer3???

SWenn.1
Senior III

Hello all...

I have 6 channels of A/D that I want to sample continuously for 480 samples total. I want these samples to be triggered on the rising edge of event out of Timer3 every 5 seconds...I have tested Timer3 using toggle and GPIO and it looks as I good. I want to use DMA to collect the samples in memory and then upon completion transfer these over the USART2 to the PC. My current application uses 6.5 as sample time with 12.5 as conversion time at 16MHz a/d clock, so collection of values happens quite fast....

My A/D settings are:

Scan Conversion Mode -- Enabled

Continuous Conversion Mode -- Enabled

DMA Continuous Requests -- Disabled

End of Conversion Selection -- End of sequence of conversion (although I don't think this matters as I do not have the ADC EOC IRQ enabled)

Do these settings in CubeMx look appropriate for the matter at hand?

I plan on having the DMA Complete ISR for the ADC then trigger the DMA to the USART to transfer data.

What is the appropriate way to stop the ADC after data capture and re-align it to the beginning of the channels for the next rising edge trigger of timer3?

By having ADC DMA Continuous Requests disabled do I have to do anything special to prepare it for the next trigger event?

Thank you

3 REPLIES 3
Piranha
Chief II

The reasoning about "End of Conversion Selection" should be correct.

Disable the "Continuous Conversion Mode" - it will stop the ADC after the completion of the sequence and make it wait for the next trigger (in your case from the timer).

Enable the "DMA Continuous Requests" - it will not disable the DMA requests after the completion of the first sequence.

All of it is explained in the reference manual and AN3116.

SWenn.1
Senior III

Continuous Conversion Mode must be "Enabled" or I won't get 480 samples each trigger event. If I disable it I get only 6 samples every trigger.

I am finding that if I Enable DMA Continuous Requests my circular DMA buffer keeps getting updated every 2ms-3ms (seen by GPIO toggle / o-scope in complete transfer callback)....If I Disable DMA Continuous Requests I only get the first DMA...seems the trigger isn't working as I want....The trigger is a 6 second square wave ....I am triggering on positive edge. Any ideas?

Piranha
Chief II

Read about the DMACFG bit. Most likely you are using DMA one shot mode and need restarting the ADC manually.