Forum: Mikrocontroller und Digitale Elektronik STM32-Stick -> PLL2 will nicht


von F. P. (pl504)


Lesenswert?

Hallo!

Meinen STM32-Perfstick2 (mit STM32F103VE) will ich gerne mit vollen 72 
MHz takten, aber irgendwas haut da noch nicht hin.

Der µC bekommt von der Peripherie einen externen Takt von 4 MHz an 
OSC_IN, daher muß ich den Umweg über die PLL2 wählen, um auf 72 MHz 
Systemtakt zu kommen (PLL1-Multiplikator geht nur bix 16x -> 64 MHz).

Leider rastet die PLL2 nicht ein - was mache ich falsch?
1
  /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration ---------------------------*/    
2
    /* Enable Prefetch Buffer */
3
    FLASH->ACR |= FLASH_ACR_PRFTBE;
4
    /* Flash 2 wait state */
5
    FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
6
    FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;    
7
    /* HCLK = SYSCLK */
8
    RCC->CFGR |= (uint32_t)RCC_CFGR_HPRE_DIV1;
9
    /* PCLK2 = HCLK */
10
    RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1;
11
    /* PCLK1 = HCLK/2 */
12
    RCC->CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2;
13
  /* Configure PLLs ------------------------------------------------------*/
14
    /* PLL2 configuration: PLL2CLK = (HSE / 1) * 10 = 40 MHz */
15
    /* PREDIV1 configuration: PREDIV1CLK = PLL2 / 5 = 8 MHz */
16
    RCC->CFGR2 &= (uint32_t)~(RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL |
17
                              RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC);
18
    RCC->CFGR2 |= (uint32_t)(RCC_CFGR2_PREDIV2_DIV1 | RCC_CFGR2_PLL2MUL10 |
19
                             RCC_CFGR2_PREDIV1SRC_PLL2 | RCC_CFGR2_PREDIV1_DIV5);
20
    /* Enable PLL2 */
21
    RCC->CR |= RCC_CR_PLL2ON;
22
    /* Wait till PLL2 is ready */
23
  
24
    while((RCC->CR & RCC_CR_PLL2RDY) == 0);      // <---- HIER BLEIBT ER HÄNGEN
25
    
26
    /* PLL configuration: PLLCLK = PREDIV1 * 9 = 72 MHz */ 
27
    RCC->CFGR &= (uint32_t)~(RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL);
28
    RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLXTPRE_PREDIV1 | RCC_CFGR_PLLSRC_PREDIV1 | 
29
                            RCC_CFGR_PLLMULL9); 
30
    /* Enable PLL */
31
    RCC->CR |= RCC_CR_PLLON;
32
    /* Wait till PLL is ready */
33
    while((RCC->CR & RCC_CR_PLLRDY) == 0);
34
    /* Select PLL as system clock source */
35
    RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
36
    RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL;    
37
    /* Wait till PLL is used as system clock source */
38
    while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08);

von Beat (Gast)


Lesenswert?

Der STM32F103VE hat keinen zweiten PLL und es existiert kein CFGR2 
Register. Mehrere PLLs gibts nur bei den Connectivity Line MCUs 
(32F105/7).

von F. P. (pl504)


Lesenswert?

Danke für die Antwort. Hatte die Hoffnung eigentlich schon aufgegeben. 
;)
Da ist ja nun alles klar.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.