Execution code in ram

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Execution code in ram

2,272 次查看
markulhu
Contributor II

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;
}

}

2 回复数

2,187 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Steven,

You can use code below to place the function into the RAM and after that just use the name of the function to call.

__attribute__ ((section(".code_ram"))) // place the code below into .code_ram section
void YourFunction(void);

Or you can check the S32_SBC[CFSR] register. For more details, please, look at the Cortex-M4 Devices Generic User Guide, chapter 4.3.10: http://infocenter.arm.com/help/topic/com.arm.doc.dui0553b/DUI0553.pdf  

I assume that you use S32K14x.

I hope it helps.

Best regards,

Diana

0 项奖励
回复

2,187 次查看
markulhu
Contributor II

Diana,thanks for your advice!  i have located the reason ,that  because the lowest bit of PC of thumb code must be 1. so i changed LoadRam's value from 0x1FFFF000 to 0x1FFFF001,  it seems running ok.

thank you for your help again!