Associate II
April 17, 2026
Question
HAL_TIM_OC_SetConfigChannel asserts on override_state
- April 17, 2026
- 1 reply
- 113 views
Hello,
I am trying to setup TIM5 channel 1 to output a signal on its output pin. I generated the code using STM32CubeMX2. I am getting an assert failed during initialization.
mx_system_init() calls mx_tim5_init() which calls HAL_TIM_OC_SetConfigChannel():
oc_config.polarity = HAL_TIM_OC_HIGH;
oc_config.idle_state = HAL_TIM_OC_IDLE_STATE_RESET;
if (HAL_TIM_OC_SetConfigChannel(&hTIM5, HAL_TIM_CHANNEL_1, &oc_config) != HAL_OK)
{
return NULL;
}In HAL_TIM_OC_SetConfigChannel function assert fails at the following line:
ASSERT_DBG_PARAM(IS_TIM_OC_OVERRIDE_STATE(p_config->override_state));
ASSERT_DBG_PARAM(IS_TIM_OC_BREAK_MODE(p_config->break_mode));The value of the override_state shown by the debugger is: (HAL_TIM_OC_OVERRIDE_SET | unknown: 0xfa). If I comment out the assert it will assert on the next line (break_mode). If I comment that line out as well the code outputs a signal on the pin.
I attached my MX2 file.
What am I missing?
-Gil
