CPU stuck in HAL_NVIC_EnableIRQ
Hi, this is my first post so I will try to provide as much information as possible. Any help is greatly appreciated! I will try to provide any missing details.
What I'm Trying To Do
- I am trying to erase sector 1 using the HAL provided APIs
- Tried HAL_FLASHEx_Erase(&p_erase_init, &page_error);
- Tried FLASH_Erase_Sector(uint32_t Sector, uint32_t Banks, uint32_t VoltageRange)
- Just for testing, I am attempting to erase sector 1 just before the while(1) loop in main
- I am using a debug LED to indicate if my program is successful (enteres the while(1) loop)
Context
- Target MCU is the STM32H755
- A custom bootloader Cortex-M7 application that lives in FLASH in 0x08000000
- The custom bootloader Cortex-M4 appliction is gutted out and runs a while (1) {}
Problem
- The CPU hangs when this function is called HAL_NVIC_EnableIRQ(pSpiIoCfg->IntrIrq);
Note
- I am unlocking the FLASH and locking FLASH afer erasing sector 1
Sample Code
FLASH_EraseInitTypeDef p_erase_init = {0};
uint32_t page_error;
p_erase_init.TypeErase = FLASH_TYPEERASE_SECTORS;
p_erase_init.Banks = FLASH_BANK_1;
p_erase_init.Sector = 1;
p_erase_init.NbSectors = 1U;
p_erase_init.VoltageRange = FLASH_VOLTAGE_RANGE_3;
HAL_FLASHEx_Erase(&p_erase_init, &page_error);
...
#if AL_EVENT_ENABLED
/* Configure GPIO as SPI interrupt input */
HW_GPIO_ClkSource(pSpiIoCfg->pIntrPort, ENABLE);
GPIO_InitStructure.Pin = pSpiIoCfg->IntrPin;
GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(pSpiIoCfg->pIntrPort, &GPIO_InitStructure);
/* Enable SPI interrupt source at NVIC */
HAL_NVIC_SetPriorityGrouping(HW_NVIC_PRIORITY_GROUP);
HAL_NVIC_SetPriority(pSpiIoCfg->IntrIrq, pSpiIoCfg->IntrPrePrio, pSpiIoCfg->IntrSubPrio);
// CPU hangs when calling this function
HAL_NVIC_EnableIRQ(pSpiIoCfg->IntrIrq);
HAL_GPIO_WritePin(USER_LED_GPIO_Port, USER_LED_Pin, 0);
#endif
...
Pin and Clock Configuration
Clock Tree

NVIC1 Settings

