cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX_LL_code enables only some devices?

Willunen
Associate III
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

1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

11 REPLIES 11
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

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

Imen.D
ST Employee
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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
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.

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

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

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

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

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