I am using TM4C123GXL EVB to build programs to erase or write to flash memory block with the interrupt driven function. However, the interrupt seems never be triggered. Following is a piece of my codes:
uint32_t eraseFlag = 0;
uint32_t DRAFlashErase(unsigned long ulAddr)
{
eraseFlag++;
FLASH_FCMISC_R = FLASH_FCMISC_PMISC & 0x2; // reset PMISC and PRIS bit in FCRIS reg to clear interrupt
FLASH_FCIM_R = FLASH_FCIM_PMASK & 0x2; // unmask bit[1] (PMASK) in the FCIM reg
// erase flash memory 1 KB block starting 0x2000
FLASH_FCMISC_R = FLASH_FCMISC_AMISC; // Clear the flash access interrupt
FLASH_FMA_R = ulAddr; // assign the starting address to FMA
FLASH_FMC_R = FLASH_FMC_WRKEY|FLASH_FMC_ERASE; // perform the erase operation...
// wait for erase complete interrupt...
while(eraseFlag)
{
if (eraseFlag == 0) { break; }
}
if(FLASH_FCRIS_R & FLASH_FCRIS_ARIS) // if FCRIS_ARIS is 1, an error occurred
{
return 1;
}
return 0;
}
void FLASH_Handler(void)
{
uint32_t readBit;
intCount++;
GPIOB->DATA = 0x01;
readBit = FLASH_CTRL->FCMISC & 0x2; // check if bit[1] on FCMISC = 1
if (readBit == 1) // either an erase or a write interrupt occurred
{
if (intCount == 1) // erase interrupt
{
GPIOB->DATA = 0x01; // Set PB0 to HIGH to indicate erasing done
eraseFlag--; // trigger while() loop in DRAFlashErase() stop
}
else // program interrupt
{
GPIOB->DATA = 0x09; // Set PB3 & PB0 to HIGH to indicate erasing done
writeFlag--; // trigger while() loop in DRAFlashWrite() stop
}
FLASH_CTRL->FCMISC = 0x2; // clear PMISC and PRIS bits to reset interrupt
}
}