Skip to main content
ttonn.1
Associate
June 19, 2022
Question

Get HardFault when debug a stm32f103 mcu when remapping timer channel with HAL lib

In order to get PWM output to PB5, I configurated the Channel2 of TIM3 to be "PWM Generattion CH2" and the PB5 pin to "TIM3_CH2". Then, the code generated and imported into STM32CubeIDE, the pointer stopped at "void HardFault_Handler(void)" function in "stm32fxxx_it.c" file. I found there are several tips reported the similar problem, but however, none of the sulutions such as comment "__HAL_AFIO_REMAP_TIM3_PARTIAL()" function and write the "AFIO_MAPR" register directly works for me. There are no differences between using ST-LINK JTAG and SWD -- both of which raises the same error.

I'm using STM32Cube FW_F1 V.18.4 with ST-Link/V2.

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
June 19, 2022

Then look at what the Hard Fault is actually reporting as the location of the fault.

Perhaps an issue with the IRQ Handler, or a structure, instance or call-back that's not completely initialized.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ttonn.1
ttonn.1Author
Associate
June 20, 2022

It seems that the "IBUSERR" bit of CFSR register is 1 while others are all 0.