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

TRAVEO™ T2G Forum Discussions

Ana0211
Level 2
Level 2
10 likes given 5 replies posted 5 likes given

Hello,

I am currently using the flash driver functions from the files cy_flash.c and cy_mw_flash.c. The function Cy_FlashWriteCode is void so there is no information about the status of the operation. Same for the Cy_FlashWriteCode function.

Is there any way to check the status of the last flash operation ?

Thank you,

Ana

0 Likes
1 Solution
Ashish
Moderator
Moderator
Moderator
25 likes received 50 solutions authored 100 replies posted

Hi Ana,

I assume you are referring to SDL api Cy_FlashWriteCode. The definition can be found in  \..\<SDL directory>\common\src\mw\flash\cy_mw_flash.c file. Kindly note that CY_ASSERT is used inside this function to check the status of api, so if it fail- then the processor will halt. If the program does not halt and goes to next line in code after executing this function, that will indicate it was executed successfully.

Ashish_1-1651221003973.png

 

Ashish_0-1651220952648.png

 

Regards,

Ashish

 

View solution in original post

3 Replies
Ashish
Moderator
Moderator
Moderator
25 likes received 50 solutions authored 100 replies posted

Hi Ana,

I assume you are referring to SDL api Cy_FlashWriteCode. The definition can be found in  \..\<SDL directory>\common\src\mw\flash\cy_mw_flash.c file. Kindly note that CY_ASSERT is used inside this function to check the status of api, so if it fail- then the processor will halt. If the program does not halt and goes to next line in code after executing this function, that will indicate it was executed successfully.

Ashish_1-1651221003973.png

 

Ashish_0-1651220952648.png

 

Regards,

Ashish

 

Ana0211
Level 2
Level 2
10 likes given 5 replies posted 5 likes given

Hello Ashish,

Thank you for your response.

I can't allow the program to halt, so I previously defined NDEBUG so that the CY_ASSERT is empty. I need to obtain the status of the flash operation and escalate an error in my software.

Is that possible ?

Thank you,

Ana

0 Likes
Ashish
Moderator
Moderator
Moderator
25 likes received 50 solutions authored 100 replies posted

Hi,

Then you can modify it (or make a similar function) to return the "status" instead of doing assert. Since it's just a middleware, and it calls Cy_Flash_ProgramRow which in turn calls system call api Cy_Flash_CallSromApiForFlashWrite for writing operation. Cy_Flash_ProgramRow will return the status as success or fail (with error code). You can refer chapter 33 "Nonvolatile memory programming" for details on system calls and various error codes. 

Regards,

Ashish

0 Likes