cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX bug report: error in generated stm32f2xx_hal_msp.c

Maciej Musia?
Associate II
Posted on February 04, 2018 at 08:16

Hello!

I found a problem with initialization code generated for TIM2 when you select Clock source as ETR2. The bug is with pin initialization for alternate function: GPIO_InitStruct.Alternate is not set to any value (let alone the desired one):

Inside function HAL_TIM_Base_MspInit:

/**TIM2 GPIO Configuration 
 PA0-WKUP ------> TIM2_ETR 
 */
 GPIO_InitStruct.Pin = GPIO_PIN_0;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

The version of CubeMX is 4.0

The problem is only with TIM2, all other timers generate proper code.

Regards,

Maciej

#cubemx-bug #cubemx-bug-report
3 REPLIES 3
Jeanne Joly
Senior III
Posted on February 12, 2018 at 10:13

Hello

xt1

,

I have just tried with CubeMX4.24 and MCU STM32L476VGTx (with TIM2 and ETR2 set as clock source). Here is the code generated :

void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)

{

......

PA0 ------> TIM2_ETR

*/

GPIO_InitStruct.Pin = GPIO_PIN_0;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF14_TIM2;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* USER CODE BEGIN TIM2_MspInit 1 */

==> Issue is not present.

Could you please tell me what MCU you are using? (the best would be to send me your ioc in order that I understand the issue).

Thanks in advance.

Jeanne

Posted on February 12, 2018 at 11:45

Hi

‌,

The MCU is stm32F207, see the attached project file.

Regards

Maciej Musiał

________________

Attachments :

bug.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hy0Q&d=%2Fa%2F0X0000000b36%2FtG1Ya.aAkX80d_zJPUYpwXNiWvmLiOVV_kzsZ52HRaw&asPdf=false
Posted on February 12, 2018 at 14:28

hello

xt1

,

Thanks for your ioc, I see your point.

I will keep you inform as soon as there is a change on that point.

Sorry for the inconvenience it may cause.

BR. Jeanne