AnsweredAssumed Answered

F103C8 Clock issue?

Question asked by flown.tesca on Mar 20, 2015
Latest reply on Mar 21, 2015 by flown.tesca
Hello,

I'm looking for some help about the main frequency. Maybe I do not understand correctly the documentation.

My test program is just a blinking LED on PORTA PIN 0.

RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
IO_ACCESS* IO_PORTA = NEW_IO_ACCESS(&GPIOA->CRL,&GPIOA->CRH,&GPIOA->IDR,&GPIOA->ODR);
IO_PORTA->PinAsOutput(0,0);
while(1)
    {
    for(unsigned int long i = 0; i<8000000; i++);
    IO_PORTA->PinToggle(0);
    }

With defaut values clock registers, this code use the HSI and run at 8MHz according the doc.

Not I want want use HSE and PLL to run at 32MHz.

So here my code:

LASH->ACR |= FLASH_ACR_LATENCY_1;
 
RCC->CR |= RCC_CR_HSEON;
while(!(RCC->CR & RCC_CR_HSERDY));
 
RCC->CFGR |= RCC_CFGR_PLLSRC_HSE;
RCC->CFGR |= RCC_CFGR_PLLMULL4;
RCC->CR |= RCC_CR_PLLON;
while(!(RCC->CR & RCC_CR_PLLRDY));
 
RCC->CFGR |= RCC_CFGR_SW_PLL;
while(!(RCC->CFGR & RCC_CFGR_SWS_PLL));
 
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
IO_ACCESS* IO_PORTA = NEW_IO_ACCESS(&GPIOA->CRL,&GPIOA->CRH,&GPIOA->IDR,&GPIOA->ODR);
IO_PORTA->PinAsOutput(0,0);


while(1)
    {
    for(unsigned int long i = 0; i<8000000; i++);
    IO_PORTA->PinToggle(0);
    }


I'm expect that my LED blinks 4x faster. But not. I tried some other comfiguration with HSI also other PLL, etc...

But whatever I did, my LED always blink at the same speed.

Is someone able to say me where is my mistake?


Thanks,



 

Outcomes