Board has 12Mhz Xtal

Any other STM32 based boards
Post Reply
lloyd-g
Posts: 9
Joined: Thu Feb 25, 2016 11:40 am

Board has 12Mhz Xtal

Post by lloyd-g » Fri Mar 18, 2016 8:40 am

Anyone know where I adjust for this in defining a board or variant?
I can't change the Xtal as it is shared with the on-board JTAG programmer.
did find

Code: Select all

## external crystal (HSE), running at 72 MHz
nucleo_f103rb.menu.device_variant.NucleoF103_HSE=Nucleo F103 @ 72 MHz w/ crystal
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.f_cpu=72000000L
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.extra_flags=-DNUCLEO_HSE_CRYSTAL -DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__ 


but does not set the xtal only f_cpu with generic defaults for clock and pll.

Followed NUCLEO_HSE_CRYSTAL but not very clear on setup.
was hoping for a

Code: Select all

#define xtal_f 8000000L

User avatar
RogerClark
Posts: 5961
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Board has 12Mhz Xtal

Post by RogerClark » Fri Mar 18, 2016 9:39 am

You need to change the PLL multiplier to suit your crystal in the variant folders wirish/boards_setup.cpp where it sets

Code: Select all

#ifndef BOARD_RCC_PLLMUL
#if NUCLEO_HSE_CRYSTAL
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
#else
#define BOARD_RCC_PLLMUL RCC_PLLMUL_16
#endif
#endif

You need to set it to i.e 6 x 12 = 72MHz

Code: Select all

#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
F_CPU is set in Boards.txt to be 72Mhz for all STM32 boards, but I don't think you need to change this, its just the main RCC PLL

If the USB on the F103 doesnt work, you may need to change the USB PLL divider, but this seems unlikely

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest