AnsweredAssumed Answered

Timer 2 (32 bit) Acting like 16 bit with encoder (stm32L4)

Question asked by shingadaddy on Jul 5, 2016
Latest reply on Jul 11, 2016 by FTITI.Walid
Howdy folks -
Those who want to make use of a 32 bit timer (used with an encoder function or even otherwise)  will find that they might get an unexpected AUTO-RELOAD of the max 16 bit value instead of the max 32 bit value. (Rolls over at 0xFFFF) That might be because of the example code you used to init the time base config. In stm32l4xx_hal_tim.c, the function TIM_Base_SetConfig() can be modified like so:

 

/* Set the Autoreload value */

 

TIMx->

ARR = 0xFFFFFFFF; // (uint32_t)Structure->Period ;

 

 Period is defined as 0xFFFF in other init spots so you can clobber that to whatever max value you want, up to a 32 bit value, for the 32 bit timers. Trying that value on a 16 bit timer might get your complainer to complain.

Just passing on my trip points here and there.

Outcomes