K22 FLASH

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K22 FLASH

683 Views
kathirkamuannak
Contributor II

Dear Sir,

I am porting my software from MK20DX128VLF5 to MK22DX256VLF5 contoller. I am storing variables in the FLASH region from address 0x1000_0000 .

 I have written a snippet like this

size = (BYTE*)&param10 - (BYTE*)&param1;

WDog1_Disable();

FLASH1_SetBlockFlash((unsigned char *)&param1, 0x10000000, size);

WDog1_Clear();//CLEAR_WATCHDOG;
WDog1_Enable();

and my bean setting is pastedImage_2.png

The same code and setting  works well for MK20DX128VLF5. But in MK22DX256VLF5. its keep on looping the flash routine byte FLASH1_SetFlash(FLASH1_TDataAddress Src, FLASH1_TAddress Dst, word Count). its keep on looping do while loop on this section 

FLASH1_RemainingDataSize = 0U;
FLASH1_CurrentCommand = FLASH1_CMD_WRITE;
FLASH1_CmdPending = TRUE;
Result = IntFlashLdd1_Write(IntFlashLdd1_DevDataPtr, (LDD_TData *)Src, Dst, (LDD_FLASH_TDataSize)Count); /* Start reading from the flash memory */
if (Result == ERR_OK) {

do {
IntFlashLdd1_Main(IntFlashLdd1_DevDataPtr);
} while (FLASH1_CmdPending);


Result = FLASH1_CmdResult;
} else {
FLASH1_CmdPending = FALSE; /* Command parameter error */
if (Result == ERR_PARAM_ADDRESS) {
Result = ERR_RANGE;
}
}
return (byte)Result;

Thanks & Regards,

A.Kathirkamu

Tags (2)
0 Kudos
Reply
1 Reply

512 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi kathirkamu annakamu,

   

    Please take care the following points:

1. sector size difference

 MK20DX128VLF5 sector size is 1Kbyte, MK22DX256VLF5  sector size is 2 KB.

Did you define the correct sector size.

2. Before write, did you do the according address erase?

If the according flash address already have data, and you didn't erase it before you write it, the flash operation will failed.

3. Disable the interrupt.

 Before the flash operation, you need to disable the global interrupt, after the flash operation is finished, you can enable the global interrupt again.

4. The launch command code should put in the RAM.

Wish it helps you!

If you still have question, please let me know!

Have a great day,
Kerry

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

0 Kudos
Reply