Clock arrangemants for STM32-F407

Discussions and support about ChibiOS/RT, the free embedded RTOS.
BobVonKnobloch
Posts: 4
Joined: Wed Jan 02, 2019 11:12 am

Clock arrangemants for STM32-F407

Postby BobVonKnobloch » Wed Jan 02, 2019 11:32 am

Hi,
I am trying to get an Olimex board (STM32_E407 Rev.F) going.
I have copied the demo files for the RT_STM32F407-DISCOVERY to RT_STM32F407-OLIMEX (in the same directory) and changed one Makefile entry to:
"include $(CHIBIOS)/os/hal/boards/OLIMEX_STM32_E407/board.mk".
Attempting to compile, the following is reported:

Compiling crt0_v7m.S
Compiling vectors.S
Compiling chcoreasm_v7m.S
Compiling crt1.c
Compiling hal.c
In file included from ../../../os/hal/include/hal.h:114,
from ../../../os/hal/src/hal.c:25:
../../../os/hal/ports/STM32/STM32F4xx/hal_lld.h:1374:2: error: #error "STM32_PLLVCO outside acceptable range (STM32_PLLVCO_MIN...STM32_PLLVCO_MAX)"
#error "STM32_PLLVCO outside acceptable range (STM32_PLLVCO_MIN...STM32_PLLVCO_MAX)"
^~~~~
and several more - all to do with PLL speed.

I am new to both Chibios and to ARM Cortex M4 processors (but quite experienced in C & Linux).
I suppose there is a config somewhere but trying to trace the 'defines backwards is quite hard.
I am running ChibiOS_18.2.1 on OpenSUSE Leap 15.0.

I would be grateful for a pointer or two as to where I should correct the clock problem.
Many thanks,

Bob von Knobloch

User avatar
Giovanni
Site Admin
Posts: 11472
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 450 times
Been thanked: 375 times
Contact:

Re: Clock arrangemants for STM32-F407

Postby Giovanni » Wed Jan 02, 2019 1:03 pm

Hi,

Clock settings are in two places:
board.h defines the clocks of the external oscillators
mcuconf.h contains the settings of PLLs, dividers, muxes etc which depend on values defined in board.h.

Make sure that:
1) Board.h is appropriate for your board (look at frequencies).
2) The settings in mcuconf.h are appropriate for frequencies defined in board.h.

Short version: take Makefile and mcuconf.h file from a demo for your board.

Giovanni

BobVonKnobloch
Posts: 4
Joined: Wed Jan 02, 2019 11:12 am

Re: Clock arrangemants for STM32-F407

Postby BobVonKnobloch » Wed Jan 02, 2019 4:58 pm

OK thanks, I will look at mcuconf.h (that may be the piece I was missing - thanks).
Short version: would love to, but you don't appear to have a demo for this board.
Best wishes,
Bob

User avatar
Giovanni
Site Admin
Posts: 11472
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 450 times
Been thanked: 375 times
Contact:

Re: Clock arrangemants for STM32-F407

Postby Giovanni » Wed Jan 02, 2019 5:02 pm

Hi,

You need to change the PLL input divider if the xtal frequency is different, everything else should be fine.

Giovanni

BobVonKnobloch
Posts: 4
Joined: Wed Jan 02, 2019 11:12 am

Re: Clock arrangemants for STM32-F407

Postby BobVonKnobloch » Thu Jan 03, 2019 10:55 am

Hi Giovanni,
In "mcuconf.h", I changed the entry "#define STM32_PLLM_VALUE" to 12 (was 8 in the demo, the ST board is 8MHz; the Olimex board is 12MHz) but still have the same error.
Any suggestions (am I using the right entry)?
Best wishes,
Bob

steved
Posts: 559
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 4 times
Been thanked: 61 times

Re: Clock arrangemants for STM32-F407

Postby steved » Thu Jan 03, 2019 2:21 pm

These are the values I use for the Olimex board (on Chibi 17.6, but doubt anything's changed):

Code: Select all

      /* Settings for Olimex E407 (12MHz crystal) */
      #define STM32_PLLM_VALUE                    12                  /* PLL input prescaler - gives 1MHz into PLL */
      #define STM32_PLLN_VALUE                    336                 /* PLL multiplier for VCO clock - gives 336MHz */
      #define STM32_PLLP_VALUE                    2                   /* PLL clock output divider - 168MHz */
      #define STM32_PLLQ_VALUE                    7                   /* Nominal 48MHz clock divider - 48MHz */

...and in board.h:

Code: Select all

#if !defined(STM32_HSECLK)
#define STM32_HSECLK                12000000U
#endif

/*
 * Board voltages.
 * Required for performance limits calculation.
 */
#define STM32_VDD                   330U

BobVonKnobloch
Posts: 4
Joined: Wed Jan 02, 2019 11:12 am

Re: Clock arrangemants for STM32-F407

Postby BobVonKnobloch » Thu Jan 03, 2019 3:48 pm

Thanks SteveD,
all working now - I just had to adjust the ports in main.c
Best wishes,

Bob


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 0 guests