cancel
Showing results for 
Search instead for 
Did you mean: 

Reading 2 ADC channels in simultaneous injected mode (possibly triggered by TIM1 CH4 capture compare) using HAL

TSant.2
Associate II

Anyone willing to share an example of such an application? Tried one myself by reading 2 ADC channels coming from 2 LM35 Analog sensors. However, I cannot make the injected ADC readings work.

I use CubeMX to configure the registers and Keil to build and flash the app. Could share my trials if anyone is willing to make some debugging.

Thanks in advance!

Note: The final application is the reading of 2 shunt resistor currents for a BLDC motor.

4 REPLIES 4
TSant.2
Associate II

Tried dual injected conversions (combined with regular conversions or not) but couldn't make it work. Can't see if the program is entering the complete injected conversion interrupt cuz it doesn't let me put a breakpoint there.

TDK
Guru

What chip?

Did you look at CubeMX examples?

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

Thanks TDK for the fast reply!

Chip: STM32F407 (Discovery board). Where can I find these CubeMX examples?

Just made some progress - seems that I forgot to check the global interrupts for ADCs checkbox in order to trigger the injected readings (attached img). Inside the ISR, the injected ADCx values can be stored in a buffer and used later on for the PI controllers. Curios to see if one could use DMA instead of IT to read the injected conversions. Anyone who tried this before and is willing to share some ideas?

I'll try next to work out the simultaneous injected mode where ADC1 works as a master for triggering the ADC2 injected readings. As of right now only the ADCs independent mode is working.

Note: HAL APIs used till this point: HAL_ADC_Start_DMA() and HAL_ADCEx_InjectedStart_IT().

TDK
Guru

> Where can I find these CubeMX examples?

Here is one example. Different board but the code should be similar if not the same.

https://github.com/STMicroelectronics/STM32CubeF4/blob/2f3b26f16559f7af495727a98253067a31182cfc/Projects/STM324xG_EVAL/Examples/ADC/ADC_InjectedConversion_Interrupt/Src/main.c

I don't see any examples for dual simultaneous mode.

The example selector in CubeIDE can also import these examples.

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