Skip to main content
pr_it
Associate III
July 21, 2020
Solved

Timer initialisation to *not* set the ARPE bit ?

  • July 21, 2020
  • 4 replies
  • 1515 views

I would like to know what is the correct way to disable a timer’s ARR preload function using the HAL library ? And once that’s done, does the ARPE bit stay low for the whole runtime, or does it have to be cleared again regularly or after specific events? (If yes, which?)

This topic has been closed for replies.
Best answer by TDK

Set htimx.Init.AutoReloadPreload to TIM_AUTORELOAD_PRELOAD_DISABLE before you call HAL_TIM_***_Init().

It'll stay the way you initialize it unless you re-initialize it with TIM_AUTORELOAD_PRELOAD_ENABLE.

4 replies

TDK
TDKBest answer
July 21, 2020

Set htimx.Init.AutoReloadPreload to TIM_AUTORELOAD_PRELOAD_DISABLE before you call HAL_TIM_***_Init().

It'll stay the way you initialize it unless you re-initialize it with TIM_AUTORELOAD_PRELOAD_ENABLE.

"If you feel a post has answered your question, please click ""Accept as Solution""."
pr_it
pr_itAuthor
Associate III
July 21, 2020

The timer handle's Init member is of type TIM_Base_InitTypeDef:

typedef struct
{
 TIM_TypeDef 
 TIM_Base_InitTypeDef Init;
 HAL_TIM_ActiveChannel Channel;
 DMA_HandleTypeDef *hdma[7];
 HAL_LockTypeDef Lock;
 __IO HAL_TIM_StateTypeDef State;
}TIM_HandleTypeDef;
 
typedef struct
{
 uint32_t Prescaler; 
 uint32_t CounterMode;
 uint32_t Period; 
 uint32_t ClockDivision; 
 uint32_t RepetitionCounter; 
} TIM_Base_InitTypeDef;

There is no htimx.Init.AutoReloadPreload -- am I using an outdated version of the HAL library ? (It came bundled as part of the GNU MCU Eclipse STM32F4 project template.)

TDK
July 21, 2020
Yes, seems like an old version. Id consider downloading STMCubeMX and using that to generate the initialization code.
You could also manipulate ARPE manually if comfortable.
"If you feel a post has answered your question, please click ""Accept as Solution""."