Skip to main content
plpc.1
Associate
December 28, 2022
Question

Why does my program always go into HardFault_Handler?

  • December 28, 2022
  • 2 replies
  • 1142 views

I just make a simple test. My cpu is stm32F303VET6,. Use Stm32cubeMx to generate a simple project with few lines of code, like:

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 /* USER CODE BEGIN 2 */

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

But everytime when it runned to MX_GPIO_Init(), then it was dead. And i found it hanged in HardFault_Handler(void). why?

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
December 28, 2022

Look at the instructions and registers at the point it faulted.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Karl Yamashita
Principal
December 28, 2022

Upload your ioc file

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
plpc.1
plpc.1Author
Associate
December 28, 2022

ok, please check the attached file. Thanks