cancel
Showing results for 
Search instead for 
Did you mean: 

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

ttonn.1
Associate

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.

2 REPLIES 2

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
Up vote any posts that you find helpful, it shows what's working..
ttonn.1
Associate

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