AnsweredAssumed Answered

Execution code in ram

Question asked by Steven Hu on Jan 25, 2020
Latest reply on Jan 29, 2020 by Steven Hu

hi, for my eeprom driver designing, i copyed the code from flash to ram,but jump to code in ram, it cause "HardFault" exception. is there any configuration that must be set manually? 

 

 

//static Std_ReturnType Eep_EnEepRam(void)

{

FTFC_FCCOB0 = 0x81; /* SETRAM */
FTFC_FCCOB1 = 0x00; /* FlexRAM available for emulated EEPROM */
FTFC_FSTAT |= 0x80; /* Launch command */
while (FTFC_FSTAT & 0x80) {}
return FTFC_FSTAT == 0? E_OK: E_NOT_OK;

}

//void Eep_Init(void)

{

const uint8* EnEepFun;
uint8* LoadRam = (void*)0x1FFFF000;
uint32 Depart;

Depart = (SIM_FCFG1 & 0xF000) >> 12;


if (Depart == 3 || Depart == 4 || Depart == 8 || Depart == 10 || Depart == 11)
{
EepRamEnabled = TRUE;
return;
}

 

EnEepFun = (const void*)Eep_EnEepRam;

(void)memcpy(LoadRam, EnEepFun, 20);
if (((Std_ReturnType(*)(void))LoadRam)() == STD_OK)
{
EepRamEnabled = TRUE;
return;
}

}

Outcomes