on an STM32F407, I changed the clock configuration as follows, to achieve a system clock of 144MHz instead of the standard 168MHz (in order to be able to use the maximum clock for ADC):
Code: Select all
#define STM32_HSE_ENABLED TRUE // HSE 8MHz
#define STM32_CLOCK48_REQUIRED TRUE
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_HSE
#define STM32_PLLM_VALUE 6
#define STM32_PLLN_VALUE 216
#define STM32_PLLP_VALUE 2 // SYSCLK 144MHz
#define STM32_PLLQ_VALUE 6 // 48MHzHowever, when compiling, the USB frequency check in os/hal/ports/STM32/LLD/OTGv1/usb_lld.h throws the error "the USB OTG driver requires a 48MHz clock". This is because of
Code: Select all
#define STM32_PLLCLKIN (STM32_HSECLK / STM32_PLLM_VALUE)I'd rather calculate the two values based on STM32_PLLCLKIN like this (changed the sequence of division and multiplication in os/hal/ports/STM32/STM32F4xx/hal.lld.h):
Code: Select all
//#define STM32_PLLVCO (STM32_PLLCLKIN * STM32_PLLN_VALUE)
#define STM32_PLLVCO ((STM32_HSECLK * STM32_PLLN_VALUE) / STM32_PLLM_VALUE)
//#define STM32_PLLI2SVCO (STM32_PLLCLKIN * STM32_PLLI2SN_VALUE)
#define STM32_PLLI2SVCO ((STM32_HSECLK * STM32_PLLI2SN_VALUE) / STM32_PLLM_VALUE)I couldn't test this yet, but am I overlooking something? Could and should this be changed in ChibiOS in general? I could send a pull request or sth...