cancel
Showing results for 
Search instead for 
Did you mean: 

hard fault when calling SBC_CleanDCache

fb
Associate III

I had some wrong bytes when transferring data over SPI, so I tried to clean the DCache. But I get a hard fault if I do this:

0693W000008xqbnQAA.pngI'm using the NUCLEO-H723ZG board.

3 REPLIES 3
Pavel A.
Evangelist III

And is D cache enabled?

Try this:

    if (SCB->CCR & SCB_CCR_DC_Msk) {
        SCB_CleanDCache();
    }

fb
Associate III

Thanks, looks like it was not enabled, because with your test, it works. It was a project created from STM32CubeMX. Is it possible to enable it in CubeMX? I added SCB_EnableDCache() in the main function, and this solves the problem as well.

Why doesn't the default CubeMX project generate code which enables it? I guess the speed difference can be big. I didn't check it, is the instruction cache not enabled by default as well?

Pavel A.
Evangelist III

> is the instruction cache not enabled by default as well?

Caches are not enabled after reset. You can check it easily: if (SCB->CCR & SCB_CCR_IC_Msk) ...

But STM32 has additional proprietary cache for internal flash, called ART.

--pa