2020-03-23 01:23 AM
I am new to using PWM, so not sure if this is a bug, invalid default settings or wrong documentation.
I configured my project using STM32CubeMX.
I'm using the internal clock, and the default setting for PRESCALER is 0. I can see in Keil using the debugger that the CNT register is counting (random value appears on each refresh), but the PWM output on the actual MCU output only updates when I update the RELOAD register.
However, if I change the PRESCALER to 1, it works. Hardware documentation says that the prescaler can be set in the range 1-65536, implying that you should subtract one in order to fit this into the 16bit sized registry.
Is the actual valid range 1-65535? If so, should STM32CubeMX change it's default value, and flag 0 as an invalid value?
Solved! Go to Solution.
2020-03-23 04:14 AM
OSPEED was set to "LOW". Increasing it to "VERY HIGH" did the trick.
thank you
(STM32CubeMX hides it away - you have to scroll the option into view in order to notice that you can change this)
2020-03-23 01:58 AM
Please discuss this in terms of TIM registers content, not in Cube/CubeMX terms.
Read out the registers in the "non-working" state and post.
JW
2020-03-23 03:46 AM
I have a logic analyzer connected to TIM2_CH4 / PB1
non-working (CNT register counts, while PSC is zero, but nothing happens on the hardware pin)
working - now output pin has PWM:
(attempt two, uploading files)
I can expand any registers if needed
2020-03-23 04:03 AM
Check GPIO OSPEEDR setting for the output pin. What is the APB clock frequency of the timer?
CCR4 has the same value in both cases, so the pulse witdth (duration) is shorter when PSC=0.
2020-03-23 04:14 AM
OSPEED was set to "LOW". Increasing it to "VERY HIGH" did the trick.
thank you
(STM32CubeMX hides it away - you have to scroll the option into view in order to notice that you can change this)