cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup regular mode(SW trigger+DMA) and inject mode(TIM1 CC4 trigger+IT) working together on the SAME adc in cubemx?

Harryzhangpro
Associate II

Hi!

i am using STM32F401CCU6 for BLDC/FOC motor control application.For foc application requirements, i need sampling 3 phase current in inject mode, vbus and motor temperature in regular mode.However, there is only 1 adc available for sampling. i tried lots of way to config my cubemx to get it work but i only did successed sampling in inject mode(regular mode not funtional). did i missed something or they just can't work together on the same adc?

Best wishes!

Harry.0693W000008wpkcQAA.png0693W000008wpkXQAQ.png0693W000008wpkSQAQ.png

PS: after i generated code, i did add HAL_ADC_Start_DMA() and HAL_ADCEx_InjectedStart_IT() in main() function. But only inject mode is avaliable for me.

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions
Harryzhangpro
Associate II

I found solution by myself.I have to set "Clock Prescaler" to "PCLK2 divided by 8" and everything going well! However I still can't understand why the MCU is not working at the division of 2? Is DMA clock problem or ADC can't handle that fast?

View solution in original post

1 REPLY 1
Harryzhangpro
Associate II

I found solution by myself.I have to set "Clock Prescaler" to "PCLK2 divided by 8" and everything going well! However I still can't understand why the MCU is not working at the division of 2? Is DMA clock problem or ADC can't handle that fast?

Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.