Hallo,
ich habe folgendes Problem, mein STM32L152RE läuft mit der halben
Frequenz.
Ich kann mir nicht erklären wieso. Bei Uart läuft er auf Baud 9600
anstatt der eingestellten 19200 und ein Timer ist auch um die Hälfte zu
langsam.
die HSI wir wie folgt konfiguriert:
1 | void SystemCoreClockSetHSI(void)
|
2 | {
|
3 | RCC->CR |= ((uint32_t)RCC_CR_HSION); /* Enable HSI */
|
4 | while ((RCC->CR & RCC_CR_HSIRDY) == 0); /* Wait for HSI Ready */
|
5 |
|
6 | RCC->CFGR = RCC_CFGR_SW_HSI; /* HSI is system clock */
|
7 | while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); /* Wait for HSI used as system clock */
|
8 |
|
9 | /* PLL configuration: PLLCLK = (HSI * 6)/3 = 32 MHz */
|
10 | RCC->CFGR &= ~(RCC_CFGR_PLLSRC |RCC_CFGR_PLLMUL | RCC_CFGR_PLLDIV );
|
11 | RCC->CFGR |= (RCC_CFGR_PLLSRC_HSI | RCC_CFGR_PLLMUL4 | RCC_CFGR_PLLDIV2 );
|
12 |
|
13 | FLASH->ACR |= FLASH_ACR_ACC64; /* Enable 64-bit access */
|
14 | FLASH->ACR |= FLASH_ACR_PRFTEN; /* Enable Prefetch Buffer */
|
15 | FLASH->ACR |= FLASH_ACR_LATENCY; /* Flash 1 wait state */
|
16 |
|
17 | RCC->APB1ENR |= RCC_APB1ENR_PWREN; /* Enable the PWR APB1 Clock */
|
18 | PWR->CR = PWR_CR_VOS_0; /* Select the Voltage Range 1 (1.8V) */
|
19 | while((PWR->CSR & PWR_CSR_VOSF) != 0); /* Wait for Voltage Regulator Ready */
|
20 |
|
21 | RCC->CFGR |= RCC_CFGR_HPRE_DIV1; /* HCLK = SYSCLK */
|
22 | RCC->CFGR |= RCC_CFGR_PPRE1_DIV1; /* PCLK1 = HCLK */
|
23 | RCC->CFGR |= RCC_CFGR_PPRE2_DIV1; /* PCLK2 = HCLK */
|
24 |
|
25 | RCC->CR &= ~RCC_CR_PLLON; /* Disable PLL */
|
26 |
|
27 | RCC->CR |= RCC_CR_PLLON; /* Enable PLL */
|
28 | while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); /* Wait till PLL is ready */
|
29 |
|
30 | RCC->CFGR &= ~RCC_CFGR_SW; /* Select PLL as system clock source */
|
31 | RCC->CFGR |= RCC_CFGR_SW_PLL;
|
32 |
|
33 | while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); /* Wait till PLL is system clock src */
|
34 | SystemCoreClockUpdate();
|
35 |
|
36 | };
|
Das habe ich aus dem Ordner von ST. Gewünscht ist eine Frequenz von 32
MHz.
Wo kann der Fehler liegen, bzw wo soll ich genau suchen.
Vielen Dank für die Hilfe
PS: Es ist ein Nucleo Board