2024-05-23 02:01 AM
Hello everybody!
I am using STM32F429 as my central controller for a project. I need to read 20 ADCs and process the signals by the 10 kHz sampling-time. I am using 14 channels of ADC1 and 6 channel of ADC3. Before, I have done it for one ADC when I used a timer as trigger and DMA for transferring data. The timer triggered the ADC conversion and DMA transferred the data to a buffer. When the conversion was finished, by using "HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)" function I could get the ADC values and run the control loop.
Now I have two different ADCs and it seems it is complicated to use two DMAs and one timer as trigger. I would be so grateful if you could suggest a solution!
Solved! Go to Solution.
2024-05-23 07:13 AM
When I used more than one ADC together before, I tried the lazy method I suggested and started the ADCs at the same time.
If all channels and ADCs use the same settings, ADC3 will always complete before ADC1 when you start your two ADCs at the same time. When ADC3 finishes the conversion, ADC1 will have just started the conversion of the seventh channel.
When ADC1 generates an interrupt, you can continue your work by making sure that both ADCs have finished the conversion.
If you plan to use different sampling times for each channel
Using your Clock prescaler, Resolution and Sampling Time settings, you can calculate how long the conversions will take and continue on your way with the interruption of whichever ADC finishes the cycle later.
2024-05-23 05:39 AM
If you have no problems with power optimization, here is a lazy solution;
If you set the ADC to sample well above 10KHz with DMA and only read from the arrays at each timer interrupt, you can get the job done.
If you have applied a filter to the ADC input in accordance with the Nyquest rule, digital signal processing algorithms will not be affected by sampling time differences of a few microseconds.
However, I am also wondering what prevents you from setting the External Trigger Conversion Source setting to the same timer for both ADCs and doing your work when ADC1's cycle is finished (ADC2 will have completed its cycle unless you set a different sampling time for each channel).
2024-05-23 05:57 AM - edited 2024-05-23 05:58 AM
Thank you for your response. But I should note that I am using two independent ADCs. (ADC1 and ADC3 are independent. 14 channels of ADC1 and 6 channels of ADC3).
I have one control loop that should be executed after end of all ADC conversion (ADC1 and ADC3). if I use one Timer trigger for both ADCs, then I will have two different DMA interrupt after ADC conversion. How can I set two independent ADCs with two different DMA for simultaneous conversion and gather their data?
2024-05-23 06:19 AM
If common settings are used, ADC3 will finish its conversion before ADC1. If you use ADC1's interrupt, you can assume that both ADCs have finished their conversion and continue your operation.
No need to use ADC3 interrupt.
2024-05-23 06:37 AM
I have to use DMA for both ADCs which implies that I will have two interrupts after ADCc conversion. Is it possible to trig ADC1 with a timer and in the interrupt of DMA of ADC1, start conversion of the ADC3 by software?
2024-05-23 07:13 AM
When I used more than one ADC together before, I tried the lazy method I suggested and started the ADCs at the same time.
If all channels and ADCs use the same settings, ADC3 will always complete before ADC1 when you start your two ADCs at the same time. When ADC3 finishes the conversion, ADC1 will have just started the conversion of the seventh channel.
When ADC1 generates an interrupt, you can continue your work by making sure that both ADCs have finished the conversion.
If you plan to use different sampling times for each channel
Using your Clock prescaler, Resolution and Sampling Time settings, you can calculate how long the conversions will take and continue on your way with the interruption of whichever ADC finishes the cycle later.
2024-05-23 08:25 AM
Thank you so much for your help.