TIM16 and LSI frequency Measurment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-06-18 5:01 AM
Hi,
I'm using STM32H743ZI. I want to measure the LSI frequency by timer TIM16.
- Configure TIM16 by CubeMX (5.2.1)
- "Input Capture direct mode from Remap"
- "TI1 remap capabilities for TIM16 => "TIM16 TI1 is connected to RCC LSI"
- TIM16 global interrupt => "Enabled"
- Call "MX_TIM16_Init()"
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.
- Labels:
-
RCC
-
STM32H7 Series
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-06-18 6: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-06-18 6:08 AM
Use HAL_TIMEx_TISelection() with TIM_TIM16_TI1_LSI
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-06-18 6: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
