cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Clock Issue

juergen2
Associate II
Posted on May 21, 2014 at 23:36

I have written

a small piece of Code

in

CooCox

. I want to use it for the F303 and for the F030.

I have noticed

that the

reset

value

is not correct.

Regarding to the reference manual the RCC for both is identically.

Reset value as written in the RM: 0x0000 XX83 where X is undefined. 

Binary

0000 0000 0000 0000 xxxx xxxx 1000 0011

Reading from F030 I got

0000 0000 0000 0001 0100 1000 1000 0011

And from F303

0000 0011 0000 0011 0100 0101 1000 0011

Why

the readout

values

does not fit to the reset values?

Thanks

This is the Code for F030, for F303 it's similar.

#include ''stm32f0xx.h''

#include ''stm32f0xx_gpio.h''

#include ''stm32f0xx_rcc.h''

int Test=0;

void wait(void);

int main(void)

{

    GPIO_InitTypeDef GPIO_InitStruct;

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;

    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;         

    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;     

    GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;     

    GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;     

    GPIO_Init(GPIOA, &GPIO_InitStruct);             

    //SystemCoreClockUpdate();

    Test=RCC->CR;

  while(1)

  {

  GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET);

  wait();

  GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_RESET);

  wait();

   }

}

void wait(void)

{

for(int i=0;i<=100000;i++)

{

}

}

4 REPLIES 4
Posted on May 22, 2014 at 00:09

Depending on your toolchain, the startup code might have written to this register.

JW
Posted on May 22, 2014 at 00:39

a) The Debugger

b) SystemInit() in system_stm32f0xx.c

c) startup_stm32f0xx.s
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
juergen2
Associate II
Posted on May 22, 2014 at 01:07

Ok, thanks.

I don't call SystemInit() in my Code, but I found these in my startup code.

bl  SystemInit

The startup

code

is

the same for both

. The F030 runs with 8MHz and the F303 runs at 72MHz.

If he

would call

SystemInit() form system_stm32f0xx.c

,

the

F030 should

run at

48MHz

???

A further question. The RM says I can feed the Systick directly with the HCLK.

But I can't found the

SysTick Control and Status Register in the RM???

 

The RCC feeds the Cortex System Timer (SysTick) external clock with the AHB clock (HCLK) divided by 8. The SysTick can work either with this clock or directly with the Cortex clock (HCLK), configurable in the SysTick Control and Status Register.

Thanks

Posted on May 22, 2014 at 01:16

ST documents the peripheral structure in the reference manual, for the core you'd want to look at the ARM TRM (Technical Reference Manual)

Joseph Yiu's books are also a good source of reference.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..