Skip to main content
fb_it
Associate III
March 24, 2021
Question

hard fault when calling SBC_CleanDCache

  • March 24, 2021
  • 3 replies
  • 1406 views

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.

This topic has been closed for replies.

3 replies

Pavel A.
March 24, 2021

And is D cache enabled?

Try this:

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

fb_it
fb_itAuthor
Associate III
March 25, 2021

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.
March 25, 2021

> 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