AnsweredAssumed Answered

Hi I am having a problem writing to onboard Flash on MK22FN256 chips.

Question asked by Starkey on Jan 4, 2016
Latest reply on Jan 7, 2016 by Alice_Yang

I am using the fsl_flash Peripheral Driver from SDK 1.2.0 on KDS 3.0.  Because this part does not have flex Ram

it only has 1 bank of flash.. Therefore when writing to the flash code must make a detour to RAM. The Driver

provides "RelocateFunction()" to move code to RAM. This works, although it does seem to have a bug (more on that later).

My problem is that the code jumps to the Ram Based function, the chip hangs up immediately.

 

 

#define LAUNCH_CMD_SIZE  0x100;

uint8_t command_sequence[LAUNCH_CMD_SIZE];

pFLASHCOMMANDSEQUENCE pFlashCommandSequence;

 

  uint32_t  pflash   = 0x00038400;

 

 

  pFlashCommandSequence = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)command_sequence , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);

  FlashEraseSector(&flash1_InitConfig0, pflash, FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE, pFlashCommandSequence);  

 

At the bottom of FlashEraseSector:

        ret = pFlashCommandSequence(pSSDConfig);

This is where it crashes.

 

I have tried writing very simple functions to execute in RAM. I cant get that to work.

I tried using the demo aps: Flash_demo_twrk22f120m it worked once and then stopped.

There must be a compiler, linker or debugger setting causing my problem.

 

Thanks


Dave Starkey

 

 

dave@pianoarc.com

dstarkey@midi9.com

Outcomes