cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong flash latency from CubeMX with STM32F302CC?

Moritz Diller
Associate II
Posted on May 19, 2018 at 19:51

My program crashes with the following error in TrueStudio:

''Program received signal SIGTRAP, Trace/breakpoint trap.

0xfffffffe in ?? ()''

The fault occurs in line 692 of stm32f3xx_hal_rcc.c:

__HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);

If I change

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0)

to

HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1)

everything works fine.

I use an external 12 MHz clock source and this configuration in CubeMX 4.25.1:

0690X0000060KnzQAE.png

According to RM0365 the flash access time depends on HCLK not SYSCLK like in RM0008 (STM32F1...), but I tried two other configurations which indicate that flash latency should rather be set according to SYSCLK:

SYSCLK = 72 MHz, HCLK = 9 MHz -> program crashes

SYSCLK = 48 MHz, HCLK = 12 MHz -> works

Did I overlook something else or is this a bug in the reference manual / CubeMX?

11 REPLIES 11
Posted on June 06, 2018 at 11:17

Sorry

Waclawek.Jan

,

I didn't see that it has been updated in the Last RM.

I'm rechecking your configuration.

Posted on June 15, 2018 at 10:40

Thank you for your answers.

In my first post I wrote that the configuration SYSCLK = 48 MHz, HCLK = 12 MHz works fine. That is only true for low temperatures (25 °C). One of our prototypes seemed to go into a hard fault after a random time, but the weather was quite hot last week and I discovered that the hard fault immediately occured when the device was heated up by a few degrees (> 30 °C).

With one wait state instead of zero the same device didn't go into hard fault.