Skip to main content
Visitor II
March 13, 2021
Solved

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

  • March 13, 2021
  • 1 reply
  • 1013 views

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 topic has been closed for replies.
    Best answer by Harryzhangpro

    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?

    1 reply

    HarryzhangproAuthorAnswer
    Visitor II
    March 18, 2021

    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?