run code on ram fault

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

run code on ram fault

1,332 次查看
jason_shang
Contributor I

I run code on RAM, it crashes into hardfault interrupt. I using SKEAZ1284

the first picture is code on flash. the second picture is the code run on RAM, but when it executes at 0x20000078 hardfault interrupt occurs. it just normal instruct read theMCR->PLACR register address into R1

pastedImage_1.pngpastedImage_2.pngpastedImage_3.png

0 项奖励
回复
3 回复数

1,155 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Shang jason,

  Could you tell me what the IDE you are using, do you just put the FLASH_LaunchCMD to RAM or the whole project to RAM.

  Take IAR project as an example, you can use this code:

#if (defined(IAR))
__ramfunc  void FLASH_LaunchCMD(uint8_t bWaitComplete)
#else
void FLASH_LaunchCMD(uint8_t bWaitComplete)
#endif
{
#if     defined(FLASH_ENABLE_STALLING_FLASH_CONTROLLER)
     MCM->PLACR |= MCM_PLACR_ESFC_MASK;          /* enable stalling flash controller when flash is busy */
#endif
    FTMRH->FSTAT = 0x80;    
    if(bWaitComplete)
    {
      // Wait till command is completed
      while (!(FTMRH->FSTAT & FTMRH_FSTAT_CCIF_MASK));
    }
}

Please also don't do the project optimization, then test it again.

Any updated information, please kindly let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,155 次查看
jason_shang
Contributor I

thanks for your suggestion, I am using keil, first I place FLASH_LaunchCMD on code section, compile the code.then copy the code data into a data array, use a function pointer jump to data array execute FLASH_LaunchCMD.

0 项奖励
回复

1,155 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi qingrong,

    Thank you for your updated information.

     When do the flash operation, especially launch the command in the RAM, customer need to disable the global interrupt at first, after the command is finished, you can enable the interrupt again.

   Do you disable the interrupt?

__disable_irq();

Launch flash command;

__enable_irq();

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复