I'm using my own board with STM32F103RET.
I've ran into weird problem - when I'm using slightly modified board config from Olimex STM32-P103, everything runs fine (led blinking correctly, uart2 communication).
The problem is, my board is using 24MHz crystal, not 8MHz like Olimex.
As I said, everything runs fine with "wrong" config:
Code: Select all
//board.h
#define STM32_HSECLK 8000000
Code: Select all
//mcuconf.h
#define STM32_NO_INIT FALSE
#define STM32_HSI_ENABLED FALSE
#define STM32_LSI_ENABLED FALSE
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED FALSE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
#define STM32_PLLMUL_VALUE 9
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV2
#define STM32_PPRE2 STM32_PPRE2_DIV2
#define STM32_ADCPRE STM32_ADCPRE_DIV4
#define STM32_USB_CLOCK_REQUIRED TRUE
#define STM32_USBPRE STM32_USBPRE_DIV1P5
#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
#define STM32_RTCSEL STM32_RTCSEL_HSEDIV
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
when I try to change the config to real values of the board
Code: Select all
//board.h
#define STM32_HSECLK 24000000
Code: Select all
//mcuconf.h
...
#define STM32_PLLMUL_VALUE 3
...
the processor seems to run at 2/3rds of the previous speed. The led is blinking slower and uart2 stops working (just gibberish on the output).
Is there anything I'm missing?
How to determine the running frequency from runtime?
Why are wrong values in config working whilst real ones are not?