Is it possible to clear SFLASH memory while programming in PSoC 4?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MeSe_4244671
Level 1
Level 1
First like given

I am using SFLASH to record user preferences but I would like to erase it when I reprogram.

Is it possible to erase SFLASH memory in each proggraming with Psoc programmer? I am using psoc4.0 .

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello,

The SFLASH does not get automatically erased when you program your device using PSoC Programmer. It is possible to erase SFLASH memory in each programming by using any of the two methods given below:

1) You can make use of the CySysSFlashWriteUserRow() API to write 0 to the desired SFLASH rows at the beginning of each program. This will be same as erasing the SFLASH.

#include <project.h>

uint8 sFlashData[CYDEV_FLS_ROW_SIZE];

int main(void)

{

    uint16 i;

    for(i=0;i<CYDEV_FLS_ROW_SIZE;i++)

    {

        sFlashData= 0;

       CySysSFlashWriteUserRow(0, sFlashData);

    }

      

    for(;;)

     {

      }

  

}

This can be done for all the four flash rows.

2) You can also use the SFLASH Update tool which gets downloaded as a part of PSoC Programmer to program the SFLASH.

pastedImage_19.png

Regards

Ekta

View solution in original post

1 Reply
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello,

The SFLASH does not get automatically erased when you program your device using PSoC Programmer. It is possible to erase SFLASH memory in each programming by using any of the two methods given below:

1) You can make use of the CySysSFlashWriteUserRow() API to write 0 to the desired SFLASH rows at the beginning of each program. This will be same as erasing the SFLASH.

#include <project.h>

uint8 sFlashData[CYDEV_FLS_ROW_SIZE];

int main(void)

{

    uint16 i;

    for(i=0;i<CYDEV_FLS_ROW_SIZE;i++)

    {

        sFlashData= 0;

       CySysSFlashWriteUserRow(0, sFlashData);

    }

      

    for(;;)

     {

      }

  

}

This can be done for all the four flash rows.

2) You can also use the SFLASH Update tool which gets downloaded as a part of PSoC Programmer to program the SFLASH.

pastedImage_19.png

Regards

Ekta