cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX STM32L433CC bug?

nichtgedacht
Senior
Posted on February 07, 2017 at 17:36

Hi

CubeMX generates the following code for a timer (timer2) with 4 PWM channels.

Each of the channels are configured with the same parameters.

Obviously for channel1 the line:

GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;

is missing. Timer2 channel 1 do not work before inserting this line by hand.

void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
{
GPIO_InitTypeDef GPIO_InitStruct;
 if(timHandle->Instance==TIM1)
 {
 /* USER CODE BEGIN TIM1_MspPostInit 0 */
/* USER CODE END TIM1_MspPostInit 0 */
 /**TIM1 GPIO Configuration 
 PA8 ------> TIM1_CH1 
 */
 GPIO_InitStruct.Pin = GPIO_PIN_8;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN TIM1_MspPostInit 1 */
/* USER CODE END TIM1_MspPostInit 1 */
 }
 else if(timHandle->Instance==TIM2)
 {
 /* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
 
 /**TIM2 GPIO Configuration 
 PA0 ------> TIM2_CH1
 PA1 ------> TIM2_CH2
 PB10 ------> TIM2_CH3
 PB11 ------> TIM2_CH4 
 */
 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);
GPIO_InitStruct.Pin = GPIO_PIN_1;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN TIM2_MspPostInit 1 */
/* USER CODE END TIM2_MspPostInit 1 */
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

BTW How can one format source code in postings at st.com?

Everything which I tried results in a mess.

There should be a preview option also.

Regards

Dieter

10 REPLIES 10
Imen.D
ST Employee
Posted on February 07, 2017 at 18:32

Hello,

Which CubeMx version are you using ? I will check your issue and come back to you as soon as I have needed details.

About 

format source code, y

ou should expand toolbar by clicking on [...] icon, then click on ''More >> Syntax Highlighter''.0690X00000605qCQAQ.png

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on February 07, 2017 at 22:28

Hi Imen

I'm using the latest CubeMX 4.19

When trying 'Syntax highlighter' the syntax of the text becomes highlighted but ugly formatted or not formatted at all.

Because there is no preview I was wondering whether I should click the send botton.

Regards

Dieter

Posted on February 08, 2017 at 17:18

Hi

Br_ggemann.Dieter

,

I cannot reproduce your issue.

Please share your .ioc fileto check this case and identify what is going wrong.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on February 08, 2017 at 19:20

If I fix the .ioc file by hand and import the project into a fresh started CubeMX, CubeMX do not complain.

But when I have then the code generated again the .ioc file becomes broken again.

In contrast the  .pdf file from the report generation reflects what the GUI is telling me.

Regards

Dieter

Posted on February 08, 2017 at 20:32

There are more errors within the .ioc file. MCU Pins are also completely wrong.

When creating a new project from scratch, doing only pinout -> peripherals and clock configuration without touching configuration tab, the error occurs again.

Posted on February 08, 2017 at 22:53

I was wrong with my statement regarding MCU pins within the .ioc file. For these pins only the green ones seems to count.

Posted on February 13, 2017 at 16:12

Hi

Are there any news to this case?

I have tested it on another Linux box wich gaves the same result.

Dieter

Posted on February 13, 2017 at 17:24

Hi

Br_ggemann.Dieter

,

Sorry for my own delay and I want to thank you for the information and screenshotsprovided,this is helpful for us.

I confirm from my side the missing line (GPIO_InitStruct.Alternate = GPIO_AF1_TIM2)for Timer2 channel 1

andI would inform you that I have

reported internally this issueand will come back to youas soon as wehave needed updates.

All comments and suggestions are welcome to improve our solutions.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen