cancel
Showing results for 
Search instead for 
Did you mean: 

STm32Cube Input Capture bug

Walter Lucetti
Associate III
Posted on April 24, 2014 at 14:18

Hi,

I would like to signal a bug using STm32Cube to configurate timers in InputCapture 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;
htimInstance = TIM12;
htimInit.Prescaler = 83;
htimInit.CounterMode = TIM_COUNTERMODE_UP;
htimInit.Period = 65535;
htimInit.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);
}

#stm32cube-input-capture
1 REPLY 1
stm32cube-t
Senior III
Posted on April 25, 2014 at 20:19

Thank you for reporting this issue. We'll look into fixing it asap.

Best Regards.