CY8C4245PVA-452Z / return value of Flash Write Row

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

cross mob
KaKo_4074056
Level 4
Level 4
Distributor - Marubun (Japan)
First like given First solution authored 25 replies posted

Hello,

Let me confirm CySysFlashWriteRow() in CyFlash.c of the auto-generated code.

This function seems to return SUCCESS in the return value even if Write Row fails. Do you think this process is appropriate?

When Write Row by system call fails, the "retValue" should contain the status of the failure, as shown below.

            if(retValue == CY_SYS_FLASH_SUCCESS)

            {

                /* Write Row */

                parameters[0u]  = (uint32) (((uint32) CY_FLASH_KEY_TWO(CY_FLASH_API_OPCODE_WRITE_ROW) <<  CY_FLASH_PARAM_KEY_TWO_OFFSET) | CY_FLASH_KEY_ONE);

                parameters[0u] |= (uint32)(rowNum << 16u);

                CY_FLASH_CPUSS_SYSARG_REG = (uint32) &parameters[0u];

                CY_FLASH_CPUSS_SYSREQ_REG = CY_FLASH_CPUSS_REQ_START | CY_FLASH_API_OPCODE_WRITE_ROW;

                CY_NOP;

                retValue = CY_FLASH_API_RETURN;

            }

However, if the subsequent clock processing is successful, the "retValue" will be overwritten with CY_SYS_FLASH_SUCCESS, as below.

            if(clkCnfRetValue == CY_SYS_FLASH_SUCCESS)

            {

                clkCnfRetValue = CySysFlashClockRestore();

                if(clkCnfRetValue != CY_SYS_FLASH_SUCCESS)

                {

                    retValue = clkCnfRetValue;

                }

            }

If Write Row is likely to fail, my customer might consider modifying the auto-generated code themselves. Em_EEPROM component ver 2.20 is used.

Thank you.

0 Likes
1 Solution
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Actually in the code:

            if(clkCnfRetValue == CY_SYS_FLASH_SUCCESS)

            {

                clkCnfRetValue = CySysFlashClockRestore();

                if(clkCnfRetValue != CY_SYS_FLASH_SUCCESS)

                {

                    retValue = clkCnfRetValue;

                }

            }

Only if clkCnfRetValue != CY_SYS_FLASH_SUCCESS, retValue will be modified to clkCnfRetValue. If CySysFlashClockRestore(); executed successfully, retValue is still the return status from Write Flash SROM API.

Best Regards,

View solution in original post

0 Likes
2 Replies
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Actually in the code:

            if(clkCnfRetValue == CY_SYS_FLASH_SUCCESS)

            {

                clkCnfRetValue = CySysFlashClockRestore();

                if(clkCnfRetValue != CY_SYS_FLASH_SUCCESS)

                {

                    retValue = clkCnfRetValue;

                }

            }

Only if clkCnfRetValue != CY_SYS_FLASH_SUCCESS, retValue will be modified to clkCnfRetValue. If CySysFlashClockRestore(); executed successfully, retValue is still the return status from Write Flash SROM API.

Best Regards,

0 Likes
KaKo_4074056
Level 4
Level 4
Distributor - Marubun (Japan)
First like given First solution authored 25 replies posted

Hi,

I misunderstood the program. Thank you so much.

Best regards,

0 Likes