2019-06-18 05:01 AM
Hi,
I'm using STM32H743ZI. I want to measure the LSI frequency by timer TIM16.
In my opinion in line 29 Register TI1SEL should be set to 0x1. But the register does not change. If I set the register manually it seems to work.
/* TIM16 init function */
void MX_TIM16_Init(void)
{
TIM_IC_InitTypeDef sConfigIC = {0};
htim16.Instance = TIM16;
htim16.Init.Prescaler = 0;
htim16.Init.CounterMode = TIM_COUNTERMODE_UP;
htim16.Init.Period = 0xFFFF;
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();
}
if (HAL_TIM_IC_Init(&htim16) != HAL_OK)
{
Error_Handler();
}
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
sConfigIC.ICFilter = 0;
if (HAL_TIM_IC_ConfigChannel(&htim16, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
if (HAL_TIMEx_RemapConfig(&htim16, TIM_TIM16_TI1_RCC_LSI) != HAL_OK)
{
Error_Handler();
}
}
Any Idea?
Regard
Jakob
Solved! Go to Solution.
2019-06-18 06:34 AM
Thank for your help.
The following does work
MX_TIM16_Init();
if ( HAL_TIMEx_TISelection( &htim16, TIM_TIM16_TI1_RCC_LSI, TIM_CHANNEL_1 ) != HAL_OK )
{
// error
}
Thank you
Jakob
2019-06-18 06:08 AM
Use HAL_TIMEx_TISelection() with TIM_TIM16_TI1_LSI
2019-06-18 06:34 AM
Thank for your help.
The following does work
MX_TIM16_Init();
if ( HAL_TIMEx_TISelection( &htim16, TIM_TIM16_TI1_RCC_LSI, TIM_CHANNEL_1 ) != HAL_OK )
{
// error
}
Thank you
Jakob