2018-07-10 01:55 PM
Hi,
I am trying to use TIM16 for timer counter for Nucleo-144 board. After init, I do have code to SetCounter/EnableCounter.
After that the counter value get from GetCounter never increase as I am expecting.
Is there anything I am missing here? Anything else I need to make counter works?
Thx
/* TIM16 init function */
void MX_TIM16_Init(void){htim16.Instance = TIM16;
htim16.Init.Prescaler = 0; htim16.Init.CounterMode = TIM_COUNTERMODE_UP; htim16.Init.Period = 0; htim16.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim16.Init.RepetitionCounter = 0; htim16.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim16) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }}
LL_TIM_SetCounter(m_tim->Instance, counter);
LL_TIM_EnableCounter(m_tim->Instance);
2018-07-10 01:59 PM
Enable clock to given timer in RCC (APBxENR)?
JW
[EDIT]
htim16.Init.Period = 0;
This tells the timer not to run.
2018-07-10 04:22 PM
Seems working after set Period to 0xFFFF. Now I have to verify if my clock divider correct or not. Thx
htim16.Init.Period = 0xFFFF;