ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.
Moderator: RoccoMarco
chrystal
Posts: 7 Joined: Sat Jan 28, 2017 3:52 pm
Post
by chrystal » Sat Jan 28, 2017 10:15 pm
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
chrystal
Posts: 7 Joined: Sat Jan 28, 2017 3:52 pm
Post
by chrystal » Sat Jan 28, 2017 11:25 pm
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
Giovanni
Site Admin
Posts: 14893 Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times
Post
by Giovanni » Sun Jan 29, 2017 6:41 am
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
chrystal
Posts: 7 Joined: Sat Jan 28, 2017 3:52 pm
Post
by chrystal » Mon Jan 30, 2017 11:45 pm
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
Thank you !!