cancel
Showing results for 
Search instead for 
Did you mean: 

Using STM32F407 timer

JSmit.51
Associate

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

3 REPLIES 3

> 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
Associate

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

@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