STM32F3 clock frequency setup

I am trying to setup the STM32F3 CW308 target board to use a much faster clock (e.g. 48MHz).

I did the following steps:

  1. Change the constants in the HAL (SystemCoreClock, return values of HAL_RCC_GetSysClockFreq, HAL_RCC_GetPCLK1Freq and HAL_RCC_GetPCLK2Freq) to 48MHz.
  2. After flashing, but before connecting to the target I set the clkgen_freq to 48MHz and wait for the ADC to lock.
  3. Connect to the device, with SimpleSerial, trying both UART baud rate of 38400 or 115200 (changed both in the HAL and on CW side for the 115200).

However I get no data on the UART line.

Is there anything elso one has to do to change the frequency of the STM32F target boards?

Hi J08nY,

As a quick test - use the original firmware & program it into the device using a 7.3728 MHz clock (default).

Then try adjusting the CLKGEN frequency up & at the same time adjust the target baud to scale. For example if you set it to 16 MHz, the new baud will be 16/7.3728*38400 = 83333.

The ADC will only work up to 105 MHz. So be sure to set the ADC clock generator mode as the “clkgen_x1” instead of the default (“clkgen_x4”).

At some point may need to adjust flash wait-states. See the file stm32f3_hal.c:

 uint32_t flash_latency = 0;
 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, flash_latency);

Watch out - there are two locations with that (for internal osc & external) so make sure you adjust the right one. Datasheet specs:

(0 wait state from 0 to 24 MHz, 1 wait state from 24 to 48 MHz
and 2 wait states above).

PS - The ChipWhisperer serial should work up to at least the 250K baud that running the stock firmware at 48 MHz would suggest. However the wait state problem might be an issue to ensure you switch to external clock only after wait states setup. I don’t know the upper limit of XTAL in freq, you might need to use a slower clock (12 MHz) that is multiplied internally.

Hi Colin,
thanks for the answers and tests, I will test them with my setup shortly.

I am also looking at clocking the chip internally (i.e. the USE_INTERNAL_CLK setup) because for example the STM32F0 is limited to 32MHz when clocked externally. However, looking at the layout of the CW308 target board for the STM32F chips, the CLK OUT pin of the chip is not routed to CLKFB/HS1/IN for CW to lock into. Is using the internal oscillator thus not supported?


On those boards I think it was too varied between product series, that we didn’t bother routing the CLKOUT. In which case the default boards wouldn’t let you directly use this method unfortunately! If you can route CLKOUT to some other pin that could be routed to ChipWhisperer that could work.