Page 1 of 1

Clock config STM32F103 Help!

Posted: Sat Jan 28, 2017 10:15 pm
by chrystal
Hello,

i'm newbie on RTOS and do really like ChibiOs.

I have a custom STM32F103C Board without external Chrystal. I don't know whether i have configured the clock correct on 56Mhz. How do i know which clock does the controller run on?

Thank you in advance! ;)

Code: Select all

#define STM32_NO_INIT                       FALSE
#define STM32_HSI_ENABLED                   TRUE
#define STM32_LSI_ENABLED                   TRUE  //FALSE
#define STM32_HSE_ENABLED                   FALSE //TRUE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSI //STM32_PLLSRC_HSE
#define STM32_PLLXTPRE                      STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE                  7 //9
#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_USB_CLOCK_REQUIRED            FALSE //TRUE
#define STM32_USBPRE                        STM32_USBPRE_DIV1P5
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL                        STM32_RTCSEL_NOCLOCK //STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0

Re: Clock config STM32F103 Help!

Posted: Sat Jan 28, 2017 11:25 pm
by chrystal
I think i did configure the clock correct

Code: Select all

#define STM32_NO_INIT                       FALSE
#define STM32_HSI_ENABLED                   TRUE // 8MHz HSI RC -> 4MHz PLL Source
#define STM32_LSI_ENABLED                   TRUE
#define STM32_HSE_ENABLED                   FALSE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL // Main clock source selection.
#define STM32_PLLSRC                        STM32_PLLSRC_HSI //STM32_PLLSRC_HSE
#define STM32_PLLXTPRE                      STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE                  14 // 8Mhz/2 = 4Mhz * 14 = 56Mhz SysClk
#define STM32_HPRE                          STM32_HPRE_DIV1 // AHB prescaler value /1 = 56Mhz
#define STM32_PPRE1                         STM32_PPRE1_DIV2 // APB 1 Prescaler: /2 -> APB1 frequency 28MHz; 36MHz max; to TIM2-7,12-14
#define STM32_PPRE2                         STM32_PPRE2_DIV1 // APB 2 Prescaler: /1 -> APB2 frequency 56MHz; 72MHz max (only with HSE); to TIM1,8-11, ADC prescaler etc
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4// ADC Prescaler: /4 -> ADC clock frequency 14MHZ; 14MHz max
#define STM32_USB_CLOCK_REQUIRED            FALSE
#define STM32_USBPRE                        STM32_USBPRE_DIV1P5 // 56Mhz / 1.5 = 37.33 Mhz
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK // microcontroller clock output
#define STM32_RTCSEL                        STM32_RTCSEL_LSI // RTC clock source STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE                    FALSE // Enables or disables the programmable voltage detector
#define STM32_PLS                           STM32_PLS_LEV0 // Sets voltage level for programmable voltage detector

Re: Clock config STM32F103 Help!

Posted: Sun Jan 29, 2017 6:41 am
by Giovanni
Hi,

You can make sure by enabling MCO, that way you can measure the actual SYSCLK frequency. Note that the pin has a limit of output frequency, you need to divide the clock by two.

Giovanni

Re: Clock config STM32F103 Help!

Posted: Mon Jan 30, 2017 11:45 pm
by chrystal
Giovanni wrote:Hi,

You can make sure by enabling MCO, that way you can measure the actual SYSCLK frequency. Note that the pin has a limit of output frequency, you need to divide the clock by two.

Giovanni

:o Thank you !!