STM32F4--How to start PWM12/TIM12?
Posted: Wed Jan 17, 2018 1:54 pm
Hi,
I'm trying to output PWM wave from a port using TIM12. Previously I succeeded in doing so on a port using TIM8, by the following code(or sth. like that):
But I got trouble when trying to achieve the goal by replacing all PWMD8 with PWMD12, and pwm8cfg with pwm12cfg(which disabled the 3rd and 4th channel, nothing else changed).
Btw: I added this in the pwm_lld.h file:
since there's smilar code for other pwm drivers above.
Note: the graph on the oscilloscope of the output of PWM12 is like quite messy, at least not PWM waves.
Could you help me with it?
I'm trying to output PWM wave from a port using TIM12. Previously I succeeded in doing so on a port using TIM8, by the following code(or sth. like that):
Code: Select all
PWMConfig pwm8cfg = {
100000, /* 1MHz PWM clock frequency. */
1000, /* Initial PWM period 1ms. */
NULL,
{
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL}
},
0,
0
};
pwmStart(&PWMD8,&pwm8cfg);
pwmEnableChannel(&PWMD8, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD8, 1100));
But I got trouble when trying to achieve the goal by replacing all PWMD8 with PWMD12, and pwm8cfg with pwm12cfg(which disabled the 3rd and 4th channel, nothing else changed).
Btw: I added this in the pwm_lld.h file:
Code: Select all
#if STM32_PWM_USE_TIM12 && !defined(__DOXYGEN__)
extern PWMDriver PWMD12;
#endif
since there's smilar code for other pwm drivers above.
Note: the graph on the oscilloscope of the output of PWM12 is like quite messy, at least not PWM waves.
Could you help me with it?