Skip to main content
Willunen
Associate III
April 3, 2018
Solved

STM32CubeMX_LL_code enables only some devices?

  • April 3, 2018
  • 11 replies
  • 2296 views
Posted on April 03, 2018 at 10:46

Using:

Truestudio for STM32 v9.0.0.0

STM32CubeMX v4.25.0

STM32F100C8

LL_drivers only

LL_Code generated by cube enables some devices, such as the USART:

LL_USART_Enable(USART1);

But for the TIMERS it doesn't.

(perhaps there is a good reason for this?)

Also, when you select a PWM output, it does not enable the output(s):

TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;

TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;

Again, why?

(Leaving a hint in int main(void) might be an idea.)

For advanced TIMERS (TIM1) it may help people who want to use PWM when this is mentioned somewhere:

LL_TIM_EnableAllOutputs(TIM1);

(I found the MOE_bit to be rather hidden in the documentation in TIMx_BDTR)

Regards,

Wilko

    This topic has been closed for replies.
    Best answer by Mohamed Mansouri
    Posted on May 09, 2018 at 14:04

    Hi

    Lunenburg.Wilko

    ,

    Thanks for your feedback and sorry for late response.

    In fact, CubeMX allows only

    the generation of C initialization code. In such a way

    , it doesn’t set off the timer and PWM

    . The user has the authority to start them in

    any part of his program, depending on his application.

    Hoping it helps you, please do not hesitate to contact me for further details.

    thanks in advance for helping to complete this thread.

    Best Regards,

    Mohamed

    11 replies

    jean-christophe Toussaint
    Associate III
    April 3, 2018
    Posted on April 03, 2018 at 14:40

    Dear Wilko

    I made the same remark as you by developing a code using an ADC triggered by a timer.

    You need to enable Timer separately

    Please, take a look to my project

    https://community.st.com/0D50X00009bMM4uSAG

     

    After choosing a Nucleo-L476RG, I reproduced that you reported

    The two lines you mentioned are generated in MX_TIM1 function

      TIM_OC_InitStruct.

    OCMode

    = LL_TIM_OCMODE_PWM1;

      TIM_OC_InitStruct.

    OCState

    = LL_TIM_OCSTATE_DISABLE;

    In stm32l4xx_ll_tim.h, I found the following comment in line 309 concerning OCState

    This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/

    Best regards

    JC

    Willunen
    WillunenAuthor
    Associate III
    April 3, 2018
    Posted on April 03, 2018 at 16:03

    Yeah, I found out there are many different ways of enabling the TIMERS, so it does make sense that ST have not selected just one and put it in STM32CubeMX.  But it would be nice to have some (better) documentation for the LL (and HAL) drivers.

    jean-christophe Toussaint
    Associate III
    April 3, 2018
    Posted on April 03, 2018 at 17:44

    Dear Wilko

    I agree with you.  A correct documentation is missing.

    To understand more deeply the HAL library, I bought the book written by Carmine

    https://leanpub.com/mastering-stm32

     

    On the other hand, I found no doc for LL drivers except some examples supplied by ST.

    For people wishing to migrate from the SPL library to LL drivers based library, I found

    a utility SPL2LL Converter v1.0.1 supplied by ST.  But I did not check its robustness.

    best regards

    JC

    ST Technical Moderator
    April 3, 2018
    Posted on April 03, 2018 at 18:02

    Hello,

    Have you followed the

    http://www.st.com/content/ccc/resource/technical/document/user_manual/72/52/cc/53/05/e3/4c/98/DM00154093.pdf/files/DM00154093.pdf/jcr:content/translations/en.DM00154093.pdf

    User manual Description of STM32F1 HAL and Low-layer drivers?

    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
    Willunen
    WillunenAuthor
    Associate III
    April 3, 2018
    Posted on April 03, 2018 at 19:29

    Hello Imen,

    Yes I  have, together with the STM32F100xE_User_Manual.chm file, which I think is a bit easier to use. And the Reference Manual (RM0041.pdf in my case).

    The reference manual is the best to find out how a certain device works but of course it doesn't tell you what LL_functions to use to configure a device.

    What would be great is a manual such as the Reference Manual but with the appropriate LL and  HAL functions instead of (or together with) the Register Settings.

    I too bought the 'Mastering STM32' book by Carmine Noviello, but as I have decided not to use the HAL_drivers but to use LL_drivers only it is less useful to me.

    Regards,

    Wilko

    jean-christophe Toussaint
    Associate III
    April 3, 2018
    Posted on April 03, 2018 at 18:28

    Dear Imen

    Yes, I found it in exploring the ST site. Without wanting to hurt you, I do not consider that a file generated by Doxygen-like utility is a usable documentation.

    For my job of teacher, in order to introduce STM32 devices to my students, I would have more pedagogical application notes and practical examples

    using LL drivers.

    Best Regards

    JC

    Mohamed Mansouri
    Visitor II
    April 17, 2018
    Posted on April 17, 2018 at 12:29

    Dear Wilko,

    Thanks for your feedback.

    To formulate and to clarify more your situation, I propose to have more details about your code and your configuration in Cubemx. So, can you please share with me your ioc (project CubeMX) or inform me please about:

    • Your configuration in CubeMX: steps
    • Code generation of the activated timer in main.c: MX_TIMx_Init(void)

    Please let me know about the code (function) that you think are missing in MX_TIMx_Init(void).

    Thanks in advance for helping to complete this thread.

    Best Regards,

    Mohamed

    Willunen
    WillunenAuthor
    Associate III
    April 18, 2018
    Posted on April 18, 2018 at 10:33

    Hi Mohamed,

    Thanks for your reaction. What I missed was a simple

    LL_TIM_EnableCounter(TIM2);

    And

    TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_ENABLE;

    in function MX_TIM2_Init

    But the real problem is the lack of clear documentation about the LL drivers. Now you have to  gather all information from the Reference Manual together with files as STM32F100xE_User_Manual.chm and the User Manual Description of STM32F1 HAL and Low-layer drivers (UM1850), browsing through the driver code itself, and checking register settings with the debugger..

    As I told Imen, what would be great would be a manual such as the Reference Manual but with the appropriate LL and  HAL functions instead of just register settings.

    You can close this question as the problems are resolved. Thanks again.

    Regards,

    Wilko

    Mohamed Mansouri
    Mohamed MansouriBest answer
    Visitor II
    May 9, 2018
    Posted on May 09, 2018 at 14:04

    Hi

    Lunenburg.Wilko

    ,

    Thanks for your feedback and sorry for late response.

    In fact, CubeMX allows only

    the generation of C initialization code. In such a way

    , it doesn’t set off the timer and PWM

    . The user has the authority to start them in

    any part of his program, depending on his application.

    Hoping it helps you, please do not hesitate to contact me for further details.

    thanks in advance for helping to complete this thread.

    Best Regards,

    Mohamed

    Willunen
    WillunenAuthor
    Associate III
    May 9, 2018
    Posted on May 09, 2018 at 16:29

    Hi Mohamed,

    Thanks, I understand. Should I do something to close this case?

    And may I ask you to look at another question from me? It has the title '

    https://community.st.com/0D50X00009XkYRlSAN

    '

    Regards,

    Wilko

    Ruslan1
    Associate II
    June 19, 2019

    Run into the same problem with stm32f100rbt!

    Configure OC output pin for TIM3 in CubeMX and then get the generated

    "TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE"

    in the code.

    What the developer tries to avoid?

    The timer isn't been started in the configuration code.

    Thinking this way all output pins should be disabled during configuration!

    I spent 2 days trying to find whats wrong!