Unable to get PLL working

Hi,

I’m working on custom firmware for the CW308 STM32F405 target. I need to run the core from PLL (e.g. 168 MHz SYSCLK, APB1=42 MHz, APB2=84 MHz) so UART and timing work correctly.

  • The stm32f4_hal.c file has three branches: USE_INTERNAL_CLK, USE_PLL and else, (

  • No matter how I set the defines, I always seem to fall into the else path. I say seems because I have attached a debugger and stepped through and the code APPEARS to be following the correct path and setting up the PLL however, no matter what values I use I end up with HSE_BYPASS with CW’s 7.37 MHz clock, which gives me HAL_RCC_GetPCLK1Freq() and HAL_RCC_GetPCLK2Freq() ≈ 7.37 MHz.

  • UART baud calculation is then wrong: USART→BRR ends up ~32, TX gets stuck in UART-WaitOnFlagForever and I only see one tiny blip on PA9.

I’ve tried:

  • Setting USE_PLL and configuring PLLM/N/P/Q for 168 MHz, and also 84

  • Setting FLASH_ACR_LATENCY_5WS before switching SYSCLK,

  • Verifying with debugger that code reaches the PLL branch.

But UART never works unless I fall back to the default HSE_BYPASS case.

Questions:

  1. What’s the intended way to configure PLL on CW308 STM32F405 targets?

  2. Is there anything in the CW setup (e.g. jumpers, HS2/OUT clock wiring, stripped-down HAL) that forces you into HSE_BYPASS?

  3. Do I need to provide my own minimal clock setup (bare-metal register writes) instead of using the provided stm32f4_hal.c

Any pointers would help — I’m just trying to get PLL-based clocks working so UART baud is stable at 1M-2M.

Thanks!

IIRC I got the PLL on the F4 working a while ago, but we might have made other changes that broke things again. I don’t recommend relying on HAL_RCC_GetPCLK1Freq to tell whether or not the PLL is working - we’ve stripped out a lot of the lower level functions, as well as anything that relies on an interrupt.

You may indeed have to mess around with some of the lower level register writes to get things working.

Thanks for the reply. Is there any other way to bump the speed on the clock without having to poke about in the registers?

I think the max speed on the clock in pin is something like 24MHz. Above that, you’re going to have to use the PLLs.