AnsweredAssumed Answered

STm32Cube Input Capture bug

Question asked by Lucetti.Walter on Apr 24, 2014
Latest reply on Apr 25, 2014 by STM32Cube-T
Hi,
I would like to signal a bug using STm32Cube to configurate timers in Input Capture mode to measure the duration of an input signal resting at low level.

Using the method described in AN4013 at page 12 I set TIM12 in Slave Reset Mode, I set rising edge as Polarity for Channel 1, and set Channel 2 in indirect mode.

The generated C code lacks in configuring Polarity for channel 2:
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_FALLING;

If you try setting "Falling edge" as polarity for Channel 1 you get the correct configuration "Rising" for channel 2...

This is the correct configuration

/* TIM12 init function */
void MX_TIM12_Init(void)
{
  TIM_ClockConfigTypeDef sClockSourceConfig;
  TIM_IC_InitTypeDef sConfigIC;
  TIM_SlaveConfigTypeDef sSlaveConfig;
 
  htim12.Instance = TIM12;
  htim12.Init.Prescaler = 83;
  htim12.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim12.Init.Period = 65535;
  htim12.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  HAL_TIM_Base_Init(&htim12);
 
  sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  HAL_TIM_ConfigClockSource(&htim12, &sClockSourceConfig);
 
  HAL_TIM_IC_Init(&htim12);
 
  sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
  sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
  sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
  sConfigIC.ICFilter = 0;
  HAL_TIM_IC_ConfigChannel(&htim12, &sConfigIC, TIM_CHANNEL_1);
 
  sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_FALLING;
  sConfigIC.ICSelection = TIM_ICSELECTION_INDIRECTTI;
  HAL_TIM_IC_ConfigChannel(&htim12, &sConfigIC, TIM_CHANNEL_2);
 
  sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
  sSlaveConfig.InputTrigger = TIM_TS_TI1FP1;
  sSlaveConfig.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
  sSlaveConfig.TriggerFilter = 0;
  HAL_TIM_SlaveConfigSynchronization(&htim12, &sSlaveConfig);
 
}


Outcomes