2024-07-25 11:25 AM
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?
2024-07-25 12:48 PM
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.
2024-07-26 04:32 AM
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 🙂
2024-07-26 05:36 AM
-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.
And this does continuous conversions, but only one channel: