9 Replies Latest reply on Feb 13, 2020 4:52 AM by RakshithM_16



      Dear support,


      I need to use Em_EEPROM in my PSoC4 project to save some data in EEPROM.


      I'm using "CE195313" code example for PSoC4 on the CY8CKIT-049-42xx.

      After compiled the example code, I debugged it to verify if the EEPROM had been written.


      Unfortunately I've encountered any problems.


      At the first debug, eepromArray[] contains all 0, so the code execute the "Em_EEPROM_Write()" with the array[15] values.

      Then the code reads again the EEPROM and now the eepromArray[] contains the array[15] values.


      Then, I power off and power on the board and make a second debug.

      In this case, when I'm read the EEPROM, the eepromArray[] is still all 0 (no data was saved in the EEPROM).


      In this second debug, I'm expecting that the EEPROM contains the array[15] values, while I found all 0.


      Have you any ideas why this behaviour?


      Thanks and regards








        • 1. Re: CE195313

          Problem solved!


          It was my fault.

          Instead of watching results on the UART, I debugged the code.

          I didn't realize that when I reprogrammed to debug the code, the EEPROM was canceled.


          I tried to verify the results through the UART and the Em_EEPROM was succesfully written!



          • 2. Re: CE195313

            Another problem:


            the project  "CE195313" works well on the CY8CKIT-049-42xx and PSoC Creator 4.2


            Now, I am importing it in my project using CY8C4245FNI-483 and PSoC Creator 4.2 but an error appears:



            "main.c:24:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__ALIGNED'"


            this error regarding the following instructions:




            /* EEPROM storage in work flash, this is defined in Em_EEPROM.c*/
            #if defined (__ICCARM__)
            #pragma data_alignment = CY_FLASH_SIZEOF_ROW
            const uint8_t Em_EEPROM_em_EepromStorage[Em_EEPROM_PHYSICAL_SIZE] = {0u};
            const uint8_t Em_EEPROM_em_EepromStorage[Em_EEPROM_PHYSICAL_SIZE]
            __ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u};
            #endif /* defined (__ICCARM__) */





            Do someones indicate why this error appears and how to solve the problem?

            Thank you


            • 3. Re: CE195313

              Hi MaTr_1730276,


              Emulated EEPROM stores all values in the flash itself. So, when you reprogrammed the device all data is lost as the entire flash is erased. Your first inference is correct.


              For your second query, I tried to reproduce the error but the only way I could recreate the error is by adding a character before __ALIGNED as shown -

              or removing a character from __ALIGNED -

              Can you please share your project or the main.c file so that we can try to debug the issue from our end?


              Thanks and Regards,

              Rakshith M B

              • 4. Re: CE195313

                Dear Rakshith,


                thank you for replay. I tried to modifiy "__" character but do not change.


                Attanched you can find my project.


                • 5. Re: CE195313

                  Hi MaTr_1730276,


                  I was getting the same error when I built your project. I then noticed that __ALIGNED was not defined. I replaced __ALIGNED(CY_FLASH_SIZEOF_ROW) = {0u}; with __attribute__((aligned(CY_FLASH_SIZEOF_ROW))) = {0u}; and I was able to build the project successfully.


                  I then tried to include cmsis_gcc.h separately and PSoC Creator was unable to find the file. This made me think that the cy_boot component in your project was not updated. So I updated the components in the project and built the project. I was able to build the project successfully.


                  Can you please try updating the components? Please refer to this thread for more information regarding how to update components - Re: Missing components in catalog


                  Thanks and Regards,

                  Rakshith M B

                  • 6. Re: CE195313

                    Hi Rakshith,


                    I have just tried your hint but maybe I have not well done the procedure (it is a little bit too complicated).

                    Today I tried to make a new project from the scratch and it has been compiled successfully.

                    This let me thought that in the previous version something got corrupted.


                    Thanks for your support

                    • 7. Re: CE195313

                      Hi MaTr_1730276,


                      1. Click on the Tools tab in the menu bar and click on Find new components -

                      2. This opens the Component Installer window. Select all the components and install them -

                      3. After this right-click on your project in the Workspace Explorer and select Update Components -

                      4. This opens the Component Update Tool. Click on Next to update all the components in the project.


                      Please let me know if you are able to update the components.


                      I have also attached the modified project for your reference.


                      Happy to help,



                      Rakshith M B

                      • 8. Re: CE195313


                        Hi Rakshith,


                           I thought it was more complicated.


                        Now it properly compiled!




                        Thank you for helping me.



                        • 9. Re: CE195313

                          Hi MaTr_1730276,


                          Glad your issue is resolved



                          Rakshith M B