cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my program always go into HardFault_Handler?

plpc.1
Associate II

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?

4 REPLIES 4

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Karl Yamashita
Lead III

Upload your ioc file

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.

ok, please check the attached file. Thanks

sorry, i uploaded a wrong ioc file. this is the correct one.​