cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0 PWM TIM with prescaler set to zero, gives no output

SSkje.1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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)

0693W000000UV9dQAG.png

View solution in original post

4 REPLIES 4

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

SSkje.1
Associate II

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)

0693W000000UUyBQAW.png

working - now output pin has PWM:

0693W000000UUyLQAW.png

(attempt two, uploading files)

 I can expand any registers if needed

berendi
Principal

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.

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)

0693W000000UV9dQAG.png