cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474 Unable to initialize more than one ADC

aldoir
Visitor

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.

2 REPLIES 2
PGump.1
Senior III

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

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.

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