hello OLIMEX - why have you set STM32 - E407 board system clock wrong ?

Started by anotherbrick, February 24, 2013, 05:47:35 PM

Previous topic - Next topic

anotherbrick

hello OLIMEX,

I have tried to RS232 communicate with STM32-E407 board
but I could not at first trial

becouse you have used 12 MHz crystal instead of 25 Mhz

after 2 day I figured out
that I had to adjsut baudrate to (9600 / 12) * 25 = 20000
in order to comunicate with the board at 9600 baud

it means the CPU is not running at 168 MHz but at a lower speed actually

I have 2 question ;

- is there a special reason for using 12 MHz instead of 25 ?
- how do I have to change clock settings in order to run at 168 MHz ?
( which lines or values do I have to change ? )

thank you

Lurch

The 25MHz crystal was only on the prototype boards, if at all. ST and others use 25MHz.
You will need to understand what is in file system_stm32f4xx.c since that is where the frequency is normally set up. There are several ways to set it up, depending on what cpu clock you want. One way would be:

/* PLLVCO = (HSE_VALUE / PLL_M) * PLL_N */   
#define PLL_M      6                       /* Possible value 0 to 63    */
#define PLL_N      168                     /* Possible value 192 to 432 */

/* SYSCLK = PLL_VCO / PLL_P */
#define PLL_P      2

/* USB OTG FS, SDIO and RNG Clock =  PLL_VCO / PLLQ */
#define PLL_Q      7

/* I2SCLK =  PLLVCO / PLLR */                         
#define PLL_R      2                       /* Possible value 2 to 7    */
                         
/******************************************************************************/

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/

  uint32_t SystemCoreClock = ((HSE_VALUE / PLL_M) * PLL_N) / PLL_P; /*!< System Clock Frequency (Core Clock) */

There are limits on the allowable VCO input and output - that's why it's good to know what the fields mean.
I choose to divide 12MHz by 2 and multiply by 168 to get the 336MHz VCO output, which is divided down by 2.
Others divide by 12 and multiply by 336 to get there - it's up to you. Best to read the manual, since there is also a value for USB-VCO that has to be set.