Announcements

Equip yourself to optimize PSoc4 MCUs for Evs at the EV Webinar. Click here to register.

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

PSoC™ 4 Forum Discussions

KaKo_4074056
Level 4
Level 4
50 sign-ins 25 sign-ins 10 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
750 replies posted 100 sign-ins 100 likes received

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
750 replies posted 100 sign-ins 100 likes received

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

Hi,

I misunderstood the program. Thank you so much.

Best regards,

0 Likes