You are here

Write Flash of CY8C4246LTI-M445 | Cypress Semiconductor

Write Flash of CY8C4246LTI-M445

Summary: 5 Replies, Latest post by Bob Marlowe on 06 Oct 2016 11:45 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
Zoltan Szabo's picture
User
3 posts

Dear All,

Im trying to write and read Flash. But it looks only reading works.

I have

/* Flash constants */
#define FLASH_ROW_SIZE_BYTES    CY_FLASH_SIZEOF_ROW
#define FLASH_ALIGNED __attribute__ ((aligned (FLASH_ROW_SIZE_BYTES)))

static const uint8 FLASH_ALIGNED flashRowDataFLASH[FLASH_ROW_SIZE_BYTES]= {2}

/* Flash data write constants */
#define FLASH_DATA_BASE_ADDRESS_BYTE    (uint32) (&flashRowDataFLASH)
#define FLASH_DATA_BASE_ADDRESS_ROW     FLASH_DATA_BASE_ADDRESS_BYTE / FLASH_ROW_SIZE_BYTES

Read as:

a = flashRowDataFLASH[0];   and get the value 2

For write:

uint8 eepromArray[CY_FLASH_SIZEOF_ROW];

eepromArray[0] = 5;

uint8 flashWriteResult;
    
flashWriteResult = CySysFlashWriteRow(FLASH_DATA_BASE_ADDRESS_ROW, eepromArray);

But after a power off-on and read the value 2 is read again not 5 as expected.

Could someone tell me please what Im doing wrong ?

Thanks

Zoltan

user_1377889's picture
User
9620 posts

The compiler is cheating you, it "remembers" the const declaration you made and takes that value to assign. Use a memcpy() call to retrieve the programmed value.

 

Bob

Zoltan Szabo's picture
User
3 posts

Thank You Bob,

Changed the read process to:

memcpy(eepromArray, flashRowDataFLASH, CY_FLASH_SIZEOF_ROW);

a = eepromArray[0];

But still read the old value after power off-on.

user_1377889's picture
User
9620 posts

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

 

Bob

Zoltan Szabo's picture
User
3 posts

The controller is built in a device with sensors and display, so I started to remove all unrelevante parts letting just the Flash part in the code and I find the problem. The Flash writing works fine, just its a 10 sec backcounter before saving and I have been to fast, and restarted the unit before it riched to end to save. So finally is solved, thank You so much for your time and for memcpy !

All the best !

Zoltan

user_1377889's picture
User
9620 posts

You are always welcome!

 

Bob

Log in to post new comments.