Skip to main content
Paul1
Senior III
September 16, 2021
Solved

PWM for Tim15.2 on STM32L476 not working

  • September 16, 2021
  • 4 replies
  • 1231 views

I have 4 PWM out working fine on Tim3.Channel1,2,3,4

But the fifth PWM isn't working Tim15Chan2 (PB15=LQFP64pin36)

The pin works fine as GPIO so I know it is wired fine.

I even tried it as PWM Tim1.Chan3N and PWM Tim8.Chan3N but neither of those work either.

I don't see anything in L476 Errata.

Any idea what I'm doing wrong? What is difference between Tim15.2 PWM versus Tim3.2 PWM that would give me trouble?

Using latest STM32Cube MX, IDE, and Compiler.

Paul

This topic has been closed for replies.
Best answer by waclawek.jan

All TIM15 registers read as 0, that means that you either don't program TIM15, or, more likely, you don't enable the TIM15 clock in RCC. Have a look at content of RCC_APB2ENR, TIM15EN is bit 16 in it.

GPIOB registers also doesn't seem right, the bitfield in GPIOB_MODER corresponding to PB15 is set to 0b11 which is Analog (you also wrote in that picture PB14, was that intentional?)

After you solve all that, make also sure TIM15_BDTR.MOE is set.

I don't use Cube/CubeMX so don't know how to fix it in that environment, sorry.

JW

4 replies

waclawek.jan
Super User
September 16, 2021

Read out and check/post TIM15 and relevant GPIO registers content.

JW

Paul1
Paul1Author
Senior III
September 17, 2021

Hope attached has clues to my problem (Runtime SFR, Code, MX Settings, Tool Versions):

  • PWM_TIM15.2_STM32L476_PR2.docx

Paul

waclawek.jan
waclawek.janBest answer
Super User
September 17, 2021

All TIM15 registers read as 0, that means that you either don't program TIM15, or, more likely, you don't enable the TIM15 clock in RCC. Have a look at content of RCC_APB2ENR, TIM15EN is bit 16 in it.

GPIOB registers also doesn't seem right, the bitfield in GPIOB_MODER corresponding to PB15 is set to 0b11 which is Analog (you also wrote in that picture PB14, was that intentional?)

After you solve all that, make also sure TIM15_BDTR.MOE is set.

I don't use Cube/CubeMX so don't know how to fix it in that environment, sorry.

JW

Paul1
Paul1Author
Senior III
September 20, 2021

JW,

Thank you, I will try your advice today

(My Typo, should have been PB15, I'll fix my doc)

I'll post solution here when it works.

Paul

Paul1
Paul1Author
Senior III
September 20, 2021

JW,

It worked, your points led me to a bug in my own coding.

Thank you

Paul