cancel
Showing results for 
Search instead for 
Did you mean: 

TIM16 and LSI frequency Measurment

jakob.brunhart
Associate III

Hi,

I'm using STM32H743ZI. I want to measure the LSI frequency by timer TIM16.

  1. Configure TIM16 by CubeMX (5.2.1)
    1. "Input Capture direct mode from Remap"
    2. "TI1 remap capabilities for TIM16 => "TIM16 TI1 is connected to RCC LSI"
    3. TIM16 global interrupt => "Enabled"
  2. 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

1 ACCEPTED SOLUTION

Accepted Solutions
jakob.brunhart
Associate III

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

View solution in original post

2 REPLIES 2

Use HAL_TIMEx_TISelection() with TIM_TIM16_TI1_LSI

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jakob.brunhart
Associate III

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