cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX generating bad code for TIM3

jafr
Associate II
Posted on November 24, 2016 at 09:51

When generating code for MDK-ARM v5 with STM32CubeMX v4.17.0 for TIM3 Ch3 you get:''GPIO_InitStruct.Alternate = GPIO_AF0_TIM3;''

in ''void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)'' (stm32f0xx_hal_msp.c)

The correct code would be: ... = GPIO_AF1_TIM3;

Have not tested generating for other IDEs.

Not a big deal, you get an error when compiling and easy to correct.
7 REPLIES 7
Imen.D
ST Employee
Posted on November 24, 2016 at 11:41

Dear User,

I have checked from my side

with STM32F030K6T, I have the correct code:

GPIO_InitStruct.Alternate = GPIO_AF1_TIM3;

Could you please precise with which device you have found this issue ? So, we can verify it and you can share your .ioc to check with you this case.

Best Regards

STMforum
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
jafr
Associate II
Posted on November 24, 2016 at 12:43

Hi,

I used the STM32F051R8Tx.

Just tried again, with same result.

Kindly,

Jan

________________

Attachments :

STM32F051R8Tx.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htpe&d=%2Fa%2F0X0000000aXS%2F9IQki.xDUHbv5JMTiVp2hmYKr1sR7dPjKo42L.lCXXE&asPdf=false
Imen.D
ST Employee
Posted on November 24, 2016 at 13:56

Dear frisk.jan,

Referring to the datasheet for STM32F051x4, STM32F051x6 and STM32F051x8 : TIM3 is configured as AF1 Alternate Function.

The specific alternate function assignments for each pin are detailed in the device

http://www.st.com/content/ccc/resource/technical/document/datasheet/55/53/3e/86/29/61/41/d9/DM00039193.pdf/files/DM00039193.pdf/jcr:content/translations/en.DM00039193.pdf

: Table 15. Alternate functions selected through GPIOB_AFR registers for port B

Best Regards

STM32.forum

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
jafr
Associate II
Posted on November 24, 2016 at 15:09

Dear,

in my case the TIM3_CH3 is on PC8, on a 64-pin STM32F051R8Tx. The blue LED is sitting on that pin on the STM32F0-Discovery.

The code below is generated by CubeMX with the MCU alone chosen, i.e. not the Discovery-board.

    /**TIM3 GPIO Configuration    

    PC8     ------> TIM3_CH3

    */

    GPIO_InitStruct.Pin = GPIO_PIN_8;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

    GPIO_InitStruct.Alternate = GPIO_AF0_TIM3;

    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

Best Regards,

Jan

Imen.D
ST Employee
Posted on November 24, 2016 at 15:24

Dear Jan,

 

I will report this issue to our CUBEMX team for checking, thank you for highlighting it.

Best Regards

STM32.forum

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Jeanne Joly
Senior III
Posted on January 06, 2017 at 14:26

Hello frisk.jan,

Your issue is corrected and delivered in CubeMX4.19. 

BR. 

Eric Dampierre

Jeanne Joly
Senior III
Posted on January 06, 2017 at 14:53

Just for your information, CubeMX4.19 will be available soon.

BR. Eric