Hallo,
mit dem STM32F107 hab ich Probleme die Clock richtig einzustellen.
Die gewünschte Clockfrequenz ist 24Mhz. Doch sobald ich die Frequenz mit
Hilfe des Oszilloskops untersuche sehe ich 38Mhz.
Anbei mein RCC-Configuration Code:
1 | void configure_RCC(void){
|
2 |
|
3 | ErrorStatus HSEStartUpStatus;
|
4 |
|
5 | /* Reset the RCC clock configuration to default reset state */
|
6 | RCC_DeInit();
|
7 |
|
8 | /* Configure the High Speed External oscillator */
|
9 | RCC_HSEConfig(RCC_HSE_ON);
|
10 |
|
11 | /* Wait for HSE start-up */
|
12 | HSEStartUpStatus = RCC_WaitForHSEStartUp();
|
13 |
|
14 | if(HSEStartUpStatus == SUCCESS)
|
15 | {
|
16 | /* Enable Prefetch Buffer */
|
17 | FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
18 |
|
19 | /* Set the code latency value: FLASH Two Latency cycles */
|
20 | FLASH_SetLatency(FLASH_Latency_2);
|
21 |
|
22 | /* Configure the AHB clock(HCLK): HCLK = SYSCLK */
|
23 | RCC_HCLKConfig(RCC_SYSCLK_Div1);
|
24 |
|
25 | /* Configure the High Speed APB2 clcok(PCLK2): PCLK2 = HCLK */
|
26 | RCC_PCLK2Config(RCC_HCLK_Div1);
|
27 |
|
28 | /* Configure the Low Speed APB1 clock(PCLK1): PCLK1 = HCLK/2 */
|
29 | RCC_PCLK1Config(RCC_HCLK_Div2);
|
30 |
|
31 | /* Configure the PLL clock source and multiplication factor */
|
32 | /* PLLCLK = HSE*PLLMul = 8*PLLMul_X = 24MHz */
|
33 | RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_4);
|
34 |
|
35 | /* Enable PLL */
|
36 | RCC_PLLCmd(ENABLE);
|
37 |
|
38 | /* Check whether the specified RCC flag is set or not */
|
39 | /* Wait till PLL is ready */
|
40 | while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
|
41 |
|
42 | /* Select PLL as system clock source */
|
43 | RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
|
44 |
|
45 | /* Get System Clock Source */
|
46 | /* Wait till PLL is used as system clock source */
|
47 | while(RCC_GetSYSCLKSource() != 0x08);
|
48 | }
|
49 | }
|
Die Messung führe ich einfach an einem Pin durch. Dieser wird ein- und
sofort wieder ausgeschaltet.
1 | GPIOE->BSRR = GPIO_Pin_10;
|
2 | GPIOE->BRR = GPIO_Pin_10;
|
Der Reset Befehl benötigt 4 Assemblerbefehle die insgesamt in 5 Takten
durchgeführt werden. D.h. das gemessene Intervall zwischen Pin-High und
Pin-Low habe ich durch 5 geteilt, um auf die Taktfrequenz zu kommen.
Hat jemand eine Idee, warum 38Mhz statt 24Mhz eingestellt werden?