Skip to main content
Associate
November 2, 2023
Question

STM32G474 HAL_FLASHEx_Erase returns error when TIM1 is enabled and TIM17 is used as systick

  • November 2, 2023
  • 5 replies
  • 1708 views

I found a strange behavior when using TIM1 / TIM17 together with HAL_FLASHEx_Erase.

I'm using CubeMX 6.9.2 to generate the project.

 

My application is using the HAL_FLASHEx_Erase function to erase some pages of the flash.

This was working fine until I enabled TIM1. When TIM1 is enabled. Basically it is enough to set the TIM1 clock source to internal using CubeMX. The flash erase function returns HAL_ERROR.

Disabling TIM17 as systick solves the problem and everything works normal. Also disabling TIM1 solves the problem.

 

Any ideas? I might have overseen some relationship between TIM1 and FLASH but I red the Refman and found nothing suspicious.

 

Regards,

Dirk.

This topic has been closed for replies.

5 replies

ST Employee
November 2, 2023

Hello @STB, which product are you using? 

Try calling HAL_FLASH_GetError 

Also, try using another timer to see if the problem is related to TIM1 specifically 

 

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.
STBAuthor
Associate
November 2, 2023

Hi !

I'm using STM32G474VET6.

As I wrote, it can be solved by either disabling TIM1 or disabling TIM17 which was used for the SysTick.

I'm currently using as workaround TIM6 for the Systick and TIM1 for the initially intented usecase.

If you are interested in reproducing it I can send a PoC for the Nucleo-G474 board.

Regards,

Dirk

ST Employee
November 2, 2023

Yes, please! 

Thank you 

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.