cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407: Cascade 16 Bit timer in encoder mode to increase count range

Markus Rudolf
Associate III
Posted on January 26, 2017 at 16:32

Hi,

I have two freshly created projects with the STM32F407 in 100 Pin LQFP housing. I admit I didn't read the datasheet properly and found out afterwards that not all timers are 32 bit timers (which I would expect in a 32 bit micro..., lesson learned...).

In both projects I use a 16 bit timer in encoder mode. I need higher count range, overflow occurs now at 65535, I would need more like 24 bit or better the full 32bit.

For one project it's feasible to rewire the two encoder phases to one of the 32bit timers (TIM2 orTIM5) which are unused, so that would be an option, though I would prefer a software fix.

In the other project I use Ethernet in RMII mode which stupidly blocks both 32bit timers for use in encoder mode as there are not enough pin remapping options (at least CubeMX says so). So this would require a complete redesign using a TQFP144 package at least (which needs more board space and has supply chain issues).

I read about the possibility of daisy chaining two 16bit timers to get a 32bit count range, but unfortunately I don't understand if and how that would work in encoder mode. The timers are pretty complex in the datasheet and I could find an example for daisy chain in encoder mode.

If someone could give me a hint how this can be accomplished I would really appreciate it.

3 REPLIES 3
Posted on January 26, 2017 at 16:47

I don't understand if and how that would work in encoder mode

It wouldn't.

JW

Markus Rudolf
Associate III
Posted on January 26, 2017 at 16:50

Somehow when there is a overflow or underflow of the first 16bit counter in encoder mode, the 2nd counter needs to be incremented or decremented.

I'm not an expert, it was just some hope it may be possible.

Posted on January 26, 2017 at 17:16

The link between the timers is a single signal, i.e. you can link to other timer underflow/overflow (here: update) as a single signal, but not the direction.

JW