cancel
Showing results for 
Search instead for 
Did you mean: 

Has anybody converted the PWM frequency and duty cycle measurement exmaple from the STM32CubeMx examples to use STM32CubeMx to configure the hardware (.ioc file to configure the timers)?

Mike Katz
Associate II
Posted on October 10, 2017 at 21:17

The 'STMCubeF2\Projects\STM32F207ZG-Nucleo\Examples\TIM\TIM_PWMInput' example configures the timers with direct calls to the HAL.

I am trying to keep all of the pin allocation and resource initialization within STM32CubMx itself.

Has anyone either created a .ioc file for this or measured frequency and duty cycle using STM32CubeMx to configure the timers?

Thanks in advance.

11 REPLIES 11
Posted on December 21, 2017 at 17:12

So perhaps 924 Hz ?

If SystemCoreClock is 8MHz, the chip isn't running at 48 MHz

TimHandle.Init.Prescaler         = 0;

TimHandle.Init.Period            = (SystemCoreClock / 38000) - 1;

sConfig.Pulse = ((TimHandle.Init.Period+1)*100)/50; // for 50% duty cycle

Accuracy here depend on the integer divisibility of the system (bus) clock

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 28, 2017 at 10:47

Hey Clive,

Thanks a lot it worked! Really appreciate your help.

BR