Author Topic: configuring STM32 using STM32CubeMX  (Read 934 times)

0 Members and 1 Guest are viewing this topic.

Offline Mtech1Topic starter

  • Contributor
  • Posts: 28
  • Country: in
configuring STM32 using STM32CubeMX
« on: March 20, 2023, 08:34:50 am »
I am trying to configure external clock(HSE) for STM32l152ccu6 using STM32CubeMX,

Code: [Select]
  *         The system Clock is configured as follow :
  *            System Clock source            = PLL (HSE)
  *            SYSCLK(Hz)                     = 72000000
  *            HCLK(Hz)                       = 72000000
  *            AHB Prescaler                  = 1
  *            APB1 Prescaler                 = 2
  *            APB2 Prescaler                 = 1
  *            HSE Frequency(Hz)              = 25000000
  *            HSE PREDIV1                    = 5
  *            HSE PREDIV2                    = 5
  *            PLL2MUL                        = 8
  *            Flash Latency(WS)              = 2

https://community.st.com/s/article/how-to-use-stm32cubemX-to-configure-high-speed-external-oscillator-and-low-speed-external-oscillator

I am not sure I am setting correct value any help please
 

Offline luiHS

  • Frequent Contributor
  • **
  • Posts: 592
  • Country: es
Re: configuring STM32 using STM32CubeMX
« Reply #1 on: March 20, 2023, 09:21:31 am »
For 32 MHz:
PLL Source HSE (24 MHz)
PLL Mult X4
PLL Div /3
 
The following users thanked this post: Mtech1

Offline Mtech1Topic starter

  • Contributor
  • Posts: 28
  • Country: in
Re: configuring STM32 using STM32CubeMX
« Reply #2 on: March 20, 2023, 10:41:24 am »
For 32 MHz:
PLL Source HSE (24 MHz)
PLL Mult X4
PLL Div /3
still I don't fully understand GUI configuration to configure clock

Please find attached screenshot
« Last Edit: March 20, 2023, 10:43:08 am by Mtech1 »
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 495
  • Country: sk
Re: configuring STM32 using STM32CubeMX
« Reply #3 on: March 20, 2023, 11:23:37 am »
.
 
The following users thanked this post: Mtech1

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: configuring STM32 using STM32CubeMX
« Reply #4 on: March 22, 2023, 04:51:40 am »
That's because it's stupid.  You should be able to say "I have a 12MHz crystal and I want a 32MHz clock" and it should figure out all the mysterious parameters for you.  :-(  (But NO, vendors seem to universally want to show off the elegant complexity of their clock generator(s) by making you configure every little separate bit.  Sigh.)

 
The following users thanked this post: tooki

Offline wek

  • Frequent Contributor
  • **
  • Posts: 495
  • Country: sk
Re: configuring STM32 using STM32CubeMX
« Reply #5 on: March 22, 2023, 05:58:18 am »
That's because it's stupid.  You should be able to say "I have a 12MHz crystal and I want a 32MHz clock" and it should figure out all the mysterious parameters for you.  :-(  (But NO, vendors seem to universally want to show off the elegant complexity of their clock generator(s) by making you configure every little separate bit.  Sigh.)
If you want it dumb, get a dumb mcu. The new STM32C0xx family has no PLL. Want 32MHz clock? Go grab a 32MHz crystal.

Beneath this clicky is a single call to HAL_RCC_OscConfig() function (maybe in some corner cases there are more, I don't Cube). You fill in a struct, mostly just telling "I have a 12MHz crystal and want a 32MHz clock" and call that function.

At the end of the day, you just can simply read the fine manual and write five lines of program which set up the two registers which do all the work.

JW
 

Online dietert1

  • Super Contributor
  • ***
  • Posts: 2071
  • Country: br
    • CADT Homepage
Re: configuring STM32 using STM32CubeMX
« Reply #6 on: March 22, 2023, 07:29:59 am »
Once the OP understands what is a clock MUX and how to configure a clock MUX in the CubeMX clock view, he can help himself. It's simple enough and CubeMX will tell you if one of the output clocks is out of range and it can resolve such issues all by itself.
For a beginner understanding the STM32 clock generators to the point where he needs "some lines of code" can take a lot of time, even if born as "reader of manuals".

Regards, Dieter
 

Offline barshatriplee

  • Regular Contributor
  • *
  • !
  • Posts: 130
  • Country: bd
Re: configuring STM32 using STM32CubeMX
« Reply #7 on: March 28, 2023, 09:59:23 am »
Did you post this question to the STM community? I think there you will get easier guidelines.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf