Skip to main content
JSmit.51
Associate
February 6, 2020
Question

Using STM32F407 timer

  • February 6, 2020
  • 3 replies
  • 942 views

According to STMCube, one may use channels 1,2 as encoder, and channels 3,4 as PWM output simultaneously.

I doubt that.

The moment the SMCR register bit 0 is activated, PWM disappeaars.

This makes sense, as there is only one counter register.

Best Regards

Johan Smit

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
February 6, 2020

> According to STMCube

You mean, CubeMX? Cube is the library, CubeMX is the clicky program.

Well, you still *can* use channels 3 and 4 as output compare, but the counter's clock is not from the internal clock anymore. This can be useful if you want to have an output indicating that the counter reaches some predetermined value (e.g. with linear encoder this can be used for endpoint detection).

It shouldn't be called "PWM" though, that would be confusing.

I don't Cube/CubeMX.

JW

JSmit.51
JSmit.51Author
Associate
February 6, 2020

Thank you.

I dont normally do CubeMX either. I like to write the registers directly.

This time I had to repurpose a board, and I thought to check if I was doing the allocations correctly.

According to CubeMX, yes.

No, not possible. No PWM on chs 3,4 if the counter is used for encoder on channels 1,2

Johan Smit

waclawek.jan
Super User
February 6, 2020

@Amel NASRI​ ,

This IMO is worth to have a look at, as it may lead to confusion. CubeMX ought to warn, that output compare may be possible, but it's not what is usually meant but PWM.

JW