2024-10-27 08:42 AM
Hi All,
I'm trying to setup 2 ADCs in continous mode but I'm failing miserably.
In CubeMX I set the first ADC in continuous mode, triggered by software, then HAL_ADC_Start_IT(&hadc1); and it works as expected (I have a callback to read the value).
Then, I go to the second ADC, setup the samme manner as the first one, but it does not work, only the first interrupt is triggered.
HAL_ADC_Start_IT(&hadc1); //only this Interrupt works
HAL_ADC_Start_IT(&hadc2);
If I change the order of the calls (hadc2 first) the first one called works and the second is never triggered.
Is there any special caveat to activate both ADCs? I'm starting to consider the possibility of this board uses a bad clone.
Solved! Go to Solution.
2024-10-27 05:42 PM
Pedro,
I found the issue: I was using a ADC_CLOCK_ASYNC_DIV1 prescaler and the first interrupt was eating all the CPU cycles. Once I switched to ADC_CLOCK_ASYNC_DIV8 (or any larger prescaler value) it was able to trigger the second interrupt.
Thanks for your time
2024-10-27 05:32 PM
Hi,
I'm not familiar with the STM32G4, however, I am aware that the ADC1 & ADC2 are "tightly coupled" in that device - you may not be able to have separate CallBacks (I assume you are using CallBacks).
I've also noted that ADC1 & ADC2 share the same interrupt vector. You may need to differentiate between them in the CallBack function...
I hope that helps.
Kind regards
Pedro
2024-10-27 05:42 PM
Pedro,
I found the issue: I was using a ADC_CLOCK_ASYNC_DIV1 prescaler and the first interrupt was eating all the CPU cycles. Once I switched to ADC_CLOCK_ASYNC_DIV8 (or any larger prescaler value) it was able to trigger the second interrupt.
Thanks for your time