Why does my test program enter the HardFault_Handler when debugging but not when programming?
My test program for my STM32F746VET6 is extremely simple. Other than MX configuring the clock and GPIO, I only have a while loop that flashes some LEDS and then divides by zero.
while (1)
{
/* USER CODE END WHILE */
uint32_t bobbycounter = 0;
uint32_t bobbycounter2 = 0;
while(1) {
if(bobbycounter++ & 0x100000)
{
STATUS_LED_1_GPIO_Port->ODR &= ~STATUS_LED_1_Pin;
STATUS_LED_2_GPIO_Port->ODR |= STATUS_LED_2_Pin;
}
else
{
STATUS_LED_1_GPIO_Port->ODR |= STATUS_LED_1_Pin;
STATUS_LED_2_GPIO_Port->ODR &= ~STATUS_LED_2_Pin;
}
if(bobbycounter > 0x800000) {
bobbycounter = bobbycounter / bobbycounter2;
}
}When I debug in MX, I get the expected behavior where I enter the HardFault_Handler and then flash the LEDS at a faster rate forever:
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
uint32_t bobbycounter_hf = 0;
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
if(bobbycounter_hf++ & 0x10000)
{
STATUS_LED_1_GPIO_Port->ODR &= ~STATUS_LED_1_Pin;
STATUS_LED_2_GPIO_Port->ODR |= STATUS_LED_2_Pin;
}
else
{
STATUS_LED_1_GPIO_Port->ODR |= STATUS_LED_1_Pin;
STATUS_LED_2_GPIO_Port->ODR &= ~STATUS_LED_2_Pin;
}
/* USER CODE END W1_HardFault_IRQn 0 */
}
}When I program a part using STM32CubeProgrammer, however, I never enter the HardFault_Handler. I don't have either watchdog enabled. What could be going wrong here?
