Skip to main content
Graduate
April 17, 2024
Solved

CubeMX STM32L4 code generation question

  • April 17, 2024
  • 1 reply
  • 839 views

Hi folks,

I use MX to generate a code for STM32L4. I noticed, when I configure timer in one pulse mode, I cannot set OC CH1 in PWM mode with CubeMX. I could set it manually after code was generated, but it would be overwritten if I run MX one more time.

Could someone explain, if it is a bug in the tool or "feature"?

 

Cheers

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello @Lex

    When working with stm32cubeMX, it's important to understand that the tool provides initial configurations but it might not cover all possible combinations or specific use cases. 

    For your specific use case, STM32CubeMX does not allow this configuration directly, you will need to manually adjust the generated code.

    To prevent overwriting your manual changes you can use the /* USER CODE BEGIN */ and /* USER CODE END */ sections provided, Alternatively, create a separate function for your PWM configuration and call this function from the main application after the MX_TIMx_Init() call.

    1 reply

    Sarra.SAnswer
    ST Employee
    April 18, 2024

    Hello @Lex

    When working with stm32cubeMX, it's important to understand that the tool provides initial configurations but it might not cover all possible combinations or specific use cases. 

    For your specific use case, STM32CubeMX does not allow this configuration directly, you will need to manually adjust the generated code.

    To prevent overwriting your manual changes you can use the /* USER CODE BEGIN */ and /* USER CODE END */ sections provided, Alternatively, create a separate function for your PWM configuration and call this function from the main application after the MX_TIMx_Init() call.