stm32f105rct6:How to configure the clock?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: barthess, RoccoMarco, utzig, lbednarz, tfAteba

BreederBai
Posts: 19
Joined: Tue Aug 14, 2018 3:57 pm

stm32f105rct6:How to configure the clock?

Postby BreederBai » Wed Aug 15, 2018 3:39 am

I want to move ChibiOS to the development board I bought. The chip on the development board is STM32F105RCT6. I found the sample program Zubax_gnss on github, but unfortunately the external crystal used by Zubax_gnss is 16MHz, and the external crystal on my development board is 8MHz. How can I configure the system clock?Is there a relevant calculation formula?

Code: Select all

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_HSI_ENABLED                   TRUE  // Needed for FLASH programming
#define STM32_LSI_ENABLED                   TRUE  // Needed for watchdog
#define STM32_HSE_ENABLED                   TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_PREDIV1
#define STM32_PREDIV1SRC                    STM32_PREDIV1SRC_HSE
#define STM32_PREDIV1_VALUE                 2
#define STM32_PLLMUL_VALUE                  9
#define STM32_PREDIV2_VALUE                 4
#define STM32_PLL2MUL_VALUE                 16
#define STM32_PLL3MUL_VALUE                 16
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE1                         STM32_PPRE1_DIV2
#define STM32_PPRE2                         STM32_PPRE2_DIV2
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_OTG_CLOCK_REQUIRED            TRUE
#define STM32_OTGFSPRE                      STM32_OTGFSPRE_DIV3
#define STM32_I2S_CLOCK_REQUIRED            FALSE
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL                        STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0

User avatar
Giovanni
Site Admin
Posts: 11307
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: stm32f105rct6:How to configure the clock?

Postby Giovanni » Wed Aug 15, 2018 6:28 am

Hi,

You just need to halve STM32_PREDIV1_VALUE, this way you get the same frequency on the PLL input. You also need to create board files for your board.

Note that changing the clock settings requires reading the RCC/clocks section of the STM32 Reference Manual, no way around this.

Giovanni

BreederBai
Posts: 19
Joined: Tue Aug 14, 2018 3:57 pm

Re: stm32f105rct6:How to configure the clock?

Postby BreederBai » Thu Aug 16, 2018 6:03 am

Thanks, I tried to halve STM32_PREDIV1_VALUE, the compiler still reported an error, then I halved STM32_PREDIV2_VALUE and compiled it again, compiling. Thank you very much for your guidance. Can you write a tutorial on the STM32 configuration clock? I think this is necessary for beginners.

User avatar
Giovanni
Site Admin
Posts: 11307
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: stm32f105rct6:How to configure the clock?

Postby Giovanni » Thu Aug 16, 2018 1:26 pm

Hi,

Each STM32 has a different clock tree, reading and understanding how RCC works on the RM is required.

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 3 guests