2019-11-04 10:24 PM
On STM32F105 chip, i need to output a pwm, then adc caputure the voltage on pwm high stable level.
So i try to set tim1 ch1 to pwm out, and then set tim1 ch2 as compare output wih no pwm to trigger adc capture with DMA. (CC2<CC1)
Eventrually, i cannot achieve this.
on cubeMX platform.
Both of above, i can step into CC interrupt, and i put gpio set in CC interrupt, the behaviour is right.
What am i wrong, I so am so confused on this, can someone help. I have been for stuck for several days.
Thanks a lot.
2019-11-05 02:11 AM
> set tim1 "Trigger Event Selection" as "Output Compare(OC2REF)",
You don't need to do that, as ADC is not set to "TIM1 trigger out event" (there may be no such setting at all, I don't check)
> and set adc "External Trigger Conversions Source" as "Timer1 capture compare 2 event", then i cannot step into adc interrupt
You need to enable the TIM1 CH2 PWM exactly as if you would want the PWM output, i.e. set up one of the PWM modes in TIM1_CCMR1, enable it in TIM1_CCER, and probably also set TIM1_BDTR.MOE. The only thing you don't need to do is actually set the given pin to AF mode. You may want to start with actually outputting the PWM to the pin, to see that the PWM on CH2 is working as you intended.
I don't use the 'F1 nor Cube/CubeMX.
JW
PS. Please change your usename to a normal nick.