2015-08-04 09:20 AM
The generated config code ''MX_TIM3_Init()'' in ''src/tim.c'' for TIM3_PWM_Output on channel 1 and 2 fails in ''HAL_TIM_PWM_ConfigChannel()'' at
assert_param(IS_TIM_OCN_POLARITY(sConfig->OCNPolarity));
assert_param(IS_TIM_OCNIDLE_STATE(sConfig->OCNIdleState));
assert_param(IS_TIM_OCIDLE_STATE(sConfig->OCIdleState));
OCNPolarity, OCNIdleState and OCIdleState are not defined.
This is the generated code:
void MX_TIM3_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
TIM_OC_InitTypeDef sConfigOC;
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 0;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&htim3);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig);
HAL_TIM_PWM_Init(&htim3);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig);
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1);
HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2);
}
after insert of
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
in ''src/tim.c'' the asserts in ''HAL_TIM_PWM_ConfigChannel()'' works fine
My fault or bug from STM32CubeMX?
#stm32cubemx-tim-config-bug?
2015-08-05 06:57 AM
Hi rohrer.alexander,
Could you precise which product you are using? -Shahrzad-2015-08-05 07:17 AM
Hi,
im using STM32CubeMX software in version 4.9.0 on Windows 10 education Firmware package for Family STM32F4 is 1.7.0 I created the Project with the board selector (STM32F4 Discovery 407VG)2015-08-06 05:05 AM
Hi rohrer.alexander,
You are right, these parameters should be initilized by CubeMx. The issue is reported to CubeMx team. -shahrzad-2015-08-19 07:46 AM
ok fine.
Is there any ticket for this bug. Where can i see if this is fixed? Alex2015-08-26 05:48 AM
Dear user,
After analysis, the issue is not a CubeMX issue but an STM32Cube HAL driver implementation issue that we'll try to fix for next official release: some assert are already done through functions such as TIM_OCx_SetConfig. The function HAL_TIM_PWM_ConfigChannel will need to be cleaned from those asserts. Best regards.