Skip to main content
nichtgedacht
Associate III
February 7, 2017
Question

CubeMX STM32L433CC bug?

  • February 7, 2017
  • 10 replies
  • 1670 views
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

    This topic has been closed for replies.

    10 replies

    ST Technical Moderator
    February 7, 2017
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    nichtgedacht
    Associate III
    February 7, 2017
    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

    ST Technical Moderator
    February 8, 2017
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Jeanne Joly
    Associate
    March 20, 2017
    Posted on March 20, 2017 at 09:35

    Hello

    Br_ggemann.Dieter

    ,

    This issue will be corrected in the next CubeMX release (4.21).

    This next release will come soon!

    BR. Eric