cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_FLASHEx_Erase returns HAL_Error only when TIM16 is activated in CubeMX. TIM16 is set up for 1Mhz PWM CH1. I am attempting to write to internal flash and have no issues until TIM16 is activated.

TDudl.1
Associate II

Additional Information:

STM32WB55

The PSC is set to 0

the ARR is set to 31

The pulse is set to 15

The problem starts when writing to internal flash after FLASHEx_Erase runs while TIM16 is activated. I tested the speeds for the given PSC, ARR and pulse, and it comes out to 1.002MHz.

Has anyone ran into this problem before?

4 REPLIES 4
TDK
Guru

FLASH and TIM are independent peripherals and should not affect one another. If HAL_FLASHEx_Erase is returning HAL_ERROR, step through and determine why exactly.

See the ErrorCode and go from there. Verify error flags in flash are clear prior to the call.

If you feel a post has answered your question, please click "Accept as Solution".

I would like to believe that, but The FLASHEx_Erase only returns HAL_ERROR when the TIM16 is activated in cubeMX (even if it isn't started). If i activate TIM17 to do the same PWM 1Mhz output, the Flash can be written fine. It is specifically TIM16. (also, I have tried this on multiple boarads)

to be more specific. The HAL_ERROR comes from FLASH_WaitForLastOperation() which is called by FLASHEx_Erase. I even rebuilt a project and only added the TIM16 and wrote a simple flash write script and it still fails when TIM16 os active.

I also cleared Error flags before the call and it didn't help. Additionally, I am getting ErrorCode 160, but can't seem to trace back what is causing it.