run code on ram fault

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

run code on ram fault

890件の閲覧回数
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 返答(返信)

713件の閲覧回数
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 件の賞賛
返信

713件の閲覧回数
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 件の賞賛
返信

713件の閲覧回数
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 件の賞賛
返信