cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX 4.9.0 TIM Config Bug?

arohrer9
Associate II
Posted on August 04, 2015 at 18:20

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?
5 REPLIES 5
Posted on August 05, 2015 at 15:57

Hi rohrer.alexander,

Could you precise which product you are using?

-Shahrzad-

arohrer9
Associate II
Posted on August 05, 2015 at 16:17

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)

Posted on August 06, 2015 at 14:05

Hi rohrer.alexander,

You are right, these parameters should be initilized by CubeMx.

The issue is reported to CubeMx team.

-shahrzad-

arohrer9
Associate II
Posted on August 19, 2015 at 16:46

ok fine.

Is there any ticket for this bug. Where can i see if this is fixed?

Alex

stm32cube-t
Senior III
Posted on August 26, 2015 at 14:48

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.