cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Flash writing and USB Host

SDall.11
Associate III

Hello everyone,
I'm working on a project with the STM32F412VET6 and I'm having an issue with flash writing when USB Host is active.
When USB Host is active and I attempt to write to flash, execution gets stuck at the FLASH_FlushCaches() function, specifically at the very first line:

if (READ_BIT(FLASH->ACR, FLASH_ACR_ICEN) != RESET)

Notably, if I remove the MX_USB_HOST_Init() function, flash writing works fine, but if I place it anywhere in the code (even after flash writing calls), the code always gets stuck at the same point.
It seems that just including the MX_USB_HOST_Init() function in the code causes some sort of issue with the stack or something else.

I've checked the stack and it seems fine, but I currently have no other ideas about what could be causing the problem.

Do you have any suggestions for me?
Thanks!

1 REPLY 1
FBL
ST Employee

Hi @SDall.11 

Try disabling the caches before initiating the flash write operation to see if the problem persists. I'm not sure how USB host initialization somehow affects the caching mechanism. Please share your project to reproduce on my end.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


I'm out of offce with limited access to my emails.
Happy New Year!