2025-01-13 05:47 PM
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
Context
Problem
Note
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
2025-01-13 06:10 PM - edited 2025-01-13 06:11 PM
Hello and welcome to the forum!
So you want to erase a sector in the internal flash of STM32H755.
SPI is not related to this so there's no any sense in enabling its interrupt (and what is "SPI interrupt source" at all?)
Remove or comment out lines 24, 27. Will it work?
2025-01-13 06:14 PM
Hangs where? If you stop the MCU in debugger where is it?
Hard Fault or perpetually locked in IRQ Handler trying and failing to clear the source.
You Erase a sector with live code in it?