2016-07-05 11:59 AM
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.2016-07-05 04:50 PM
Always important to define the wrap point with appropriate Period setting.
2016-07-06 06:15 AM
Yeah being a generally critical parameter, you can't necessarily rely on those POWER ON RESET VALUES specified in the manual when you have example code ''Helping you out!'' Especially since it was probably for one of the 16 bit timers in the first place. ;)
2016-07-06 06:52 AM
And if you're following things to the strict level and using the function
HAL_TIM_Encoder_Init ( which calls TIM_Base_SetConfig() ) You can set ->Period herehtim2.
Init
.
CounterMode
= TIM_COUNTERMODE_UP;
htim2.Init
.
Period
= 0xFFFFFFFF;
htim2.Init
.
ClockDivision
= TIM_CLOCKDIVISION_DIV1;
sConfig.EncoderMode
= TIM_ENCODERMODE_TI1;
sConfig.IC1Polarity
= TIM_ICPOLARITY_RISING;
sConfig.IC1Selection
= TIM_ICSELECTION_DIRECTTI;
sConfig.IC1Prescaler
= TIM_ICPSC_DIV1;
sConfig.IC1Filter
= 0; sConfig.IC2Polarity
= TIM_ICPOLARITY_RISING;
sConfig.IC2Selection
= TIM_ICSELECTION_DIRECTTI;
sConfig.IC2Prescaler
= TIM_ICPSC_DIV1;
sConfig.IC2Filter
= 0;HAL_TIM_Encoder_Init(&htim2, &sConfig); A little more fitting to the example code way, than hacking it in with the previous suggestion I made.
2016-07-11 07:02 AM
Hi ,
The AHB and APB bridge interfaces have a fixed width which is one word . (As mentionned by ARMhttp://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0226a/I144880.html
). So, all registers are aligned in 4 bytes to be written only in one word. -Hannibal-