Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAL_InitTick() timer interrupt enabled before timer handle initialized #38

Open
elliott-bfs opened this issue Jun 6, 2024 · 0 comments

Comments

@elliott-bfs
Copy link

elliott-bfs commented Jun 6, 2024

Describe the set-up

  • Custom board with STM32H743BIT6 microcontroller
  • CubeMX 6.8.0
  • IAR Workbench 9.2 (CLI V9.3.2.391)

Describe the bug

In stm32h7xx_hal_timebase_tim.c, the HAL_InitTick() function enables the selected timer's IRQ before initialization the timer handle. When a software reset occurs (under debug), this results in the interrupt firing as soon as it is enabled, resulting in a HardFault because the handle has not been initialized. The htim6.Instance is equal to 0 when the interrupt occurs.

How to reproduce the bug (skip if none)

  1. In CubeMX, select TIM6 source for SysTick
  2. Build, load and run project under debug
  3. Restart program (still under debug)
  4. HardFault occurs within HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);

Additional context

A simple solution would be to move the IRQ enable after the timer initialization. For example:
stm32h7xx_hal_timebase_tim.c.patch

Screenshots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant