I'm currently having an issue with enabling my external 8MHz clock. When i begin the compile I get the error directive "the USB driver requires a 48MHz clock" yet my USB clock should be 48 MHz if I have done my math properly.
PLLCLKOUT = PLLCLKIN * PLL_MULL_VAL = 8 MHz * 9 = 72 MHZ
USBCLK = (PLLCLKOUT *2)/3 = 48 MHz
For some reason when I do a trace I get that the USBPRE is going to the case USBPRE_DIV1 instead of USBPRE_DIV1P5 which is what is needed for the 48MHz yet this is the definition I have it set to. Doing a file search i cannot find any other place where this may be redefined to DIV1. Cleaning the project in Keil doesn't seem to help either. Any ideas of what I'm doing wrong?
I am using an STM32F103VG microcontroller and chibios 2.4.2 with the following settings:
/*
* HAL driver system settings.
*/
#define STM32_NO_INIT FALSE
#define STM32_HSI_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#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_DIV2
#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_LSI
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
I also added the HSE bypass to my hal_lld.h and board.h.