cancel
Showing results for 
Search instead for 
Did you mean: 

Single Conversion Mode for Multi-channel Reading

johnjones
Associate II

I m using an STM32 Nucleo F334R8 (for the first time) to control an Inverter. i m having problmes with the ADC channels reading. I have 6 ADC1 channel and 2 ADC2 channels. these channels are going to serve the following purposes:
1. All the channels have to be read, and printed using USART2, when a usart interrupt accurs. The reading should be timed by tim6, and the values of all the channels should be stored in array, the printing happens for 40 times and stops, so i can get a good sample of the read data.
2. the 2 adc2 channels and 1 of adc 1 channels have to be continuously read when a PWM of 40Khz is generated using tim1, in order to be used in PLL controls and other PI controls. 

is what i m trying to do feasable? if yes should use DMA?
 

3 REPLIES 3
TDK
Guru

Yes this is very doable.

Using DMA to store the ADC data is the proper approach.

The DMA can be used to send out UART data, but it is not necessary.

Store ADC values into a continuous buffer and read them out or process them in the main loop as needed.

If you feel a post has answered your question, please click "Accept as Solution".

Hi, thank you for the answer, there are some configurations that i m struggling with.
I wan t to be able to read each channel individualy, because for example for the control mechanisms, i only need some of the channels, and in other parts i need to calculate the RMS for some AC signals, so

*should i enable or disable:
-scan conversion mode

-continuous conversion mode

-discontinuous conversion mode

-continuous DMA requests

*should the end of conversion selection be: end of sequence or end of single conversion

*if i have 6chennels on adc1, what number should is set these to:

-number of converion 

-sequencerNbRanks 

*and since i m using Tim for printing and tim1 for the calling for the control mechanism, should the External trigger conversion source be regular conversion set by software?
thank you in advance

-scan conversion mode

enabled

-continuous conversion mode

enabled

-discontinuous conversion mode

disabled

-continuous DMA requests

enabled

*should the end of conversion selection be: end of sequence or end of single conversion

end of sequence

*if i have 6chennels on adc1, what number should is set these to:

-number of converion 

6

-sequencerNbRanks 

6

 

You can see an example with 3 channels here, although it doesn't use continuous conversion mode.

STM32CubeF3/Projects/STM32F303RE-Nucleo/Examples/ADC/ADC_Sequencer/Src/main.c at 7d3d394a3ac57b85acd09e3fd351ce5de3db6f8b · STMicroelectronics/STM32CubeF3 (github.com)

 

And this does continuous conversions, but only one channel:

STM32CubeF3/Projects/STM32F303ZE-Nucleo/Examples/ADC/ADC_Sequencer/Src/main.c at 7d3d394a3ac57b85acd09e3fd351ce5de3db6f8b · STMicroelectronics/STM32CubeF3 (github.com)

If you feel a post has answered your question, please click "Accept as Solution".