8 Replies Latest reply on Aug 9, 2013 5:17 AM by user_1377889

    Emulated EEPROM

    ankc

      I know the flash in PSoC 4 is emulated as EEPROM, which block of Flash is emaulated as EEPROM?

         

      Is it is configurable as in PSoC 1 ? I would like to have the last block of EEPROM to be emaulated as EEPROM.

         

      Thanks,

         

      -Anandh

        • 1. Re: Emulated EEPROM
          user_14586677

          Its not configurable same way as PSOC 1, however you could always

             

          use the example project and look at the map file to determine where it

             

          was placed.

             

           

             

          Alternatively just use the low level FLASH write functions and a pointer

             

          and set your own location. There is a whole section in the TRM discussing

             

          the interface/read/write to NVM.

             

           

             

          Regards, Dana.

          • 2. Re: Emulated EEPROM
            user_1377889

            The EEEProm is quite easy to use: you just define an area of memory in flash (using the "const" directive) and give the address and size of the area to the write-function. The Emulated EEProm usermodule has no configurable parameters, everything is done via the APIs.

               

             

               

            Bob 

            • 3. Re: Emulated EEPROM
              user_14586677

              Bob is correct I think, if you want an absolute address

                 

              location for EEPROM you would have to use pointer only for GCC

                 

              on to effect array it to an absolute address.

                 

               

                 

              Different ARM compilers handle this differently.

                 

               

                 

              www.keil.com/support/docs/2829.htm     GCC, Realview

                 

               

                 

              www.cypress.com/      Keil ARM

                 

               

                 

              Regards, Dana.

              • 4. Re: Emulated EEPROM
                user_14586677

                Question for Bob.

                   

                 

                   

                Using pointer approach, is compile smart enough to keep track

                   

                of all the absolute addresses used ? To know how much memory

                   

                to set aside for EEPROM use, and where it is so it does not map

                   

                over the EEPROM with other stuff ?

                   

                 

                   

                I am not so sure now just using a pointer will work. I still think one

                   

                still needs to set aside memory needed with an absolute directive.

                   

                 

                   

                Your thoughts ?

                   

                 

                   

                Regards, Dana.

                • 5. Re: Emulated EEPROM
                  user_1377889

                  Dana,

                     

                  for the sake of my so much propagated "Readability" I would always use a different approach.

                     

                  something like

                     

                  #define EEEPROMSIZE 1001

                     

                  const uint8 EEEPromArea[EEEPROMSIZE];

                     

                   

                     

                  or

                     

                   

                     

                  const struct sMyEEEProm { uint8 IsProgrammed; uint8 Data[EEPROMSIZE];} MyEEEProm;

                     

                  and later using in the code

                     

                   

                     

                  Result = EEEProm_Write(MyData,EEEPromArea,EEEPROMSIZE);

                     

                  or

                     

                  Result = EEEProm_Write(MyData,(uint8 *)(& struct sMyEEEProm),sizeof(struct sMyEEEProm));

                     

                   

                     

                  This way even arrays of a struct are possible with writes to a single element within a certain struct can be performed.

                     

                  With freedom comes responsibility: DO NOT OVERWRITE YOUR CODE!!!

                     

                   

                     

                  Bob (Hoping for only few typos)

                  • 6. Re: Emulated EEPROM
                    user_1377889

                    What suddenly brings to my mind the "problem" of self-modifying code. I do not like the thought of that

                       

                     

                       

                    Bob

                    • 7. Re: Emulated EEPROM
                      user_14586677

                      Of course this approach still does not force the EEPROM to

                         

                      the last addresses in FLASH memory as originally stated

                         

                      as a goal.

                         

                       

                         

                      Regards, Dana.

                      • 8. Re: Emulated EEPROM
                        user_1377889

                        Of course (or rather "curse" ) you may assign *ANY* hex value to a pointer.

                           

                        Having an end-of-flash which would be

                           

                        #define MY_FLASH_END CY_FLASH_BASE + CY_FLASH_SIZE

                           

                        one could easily calculate the location of an EEEPROM_START when the size is know and assigning that calculated address to a pointer of a structure that organizes the EEEProm-area.

                           

                        This will be target and compiler independent as long as one adjusts the #defines for flash start and size.

                           

                         

                           

                        Bob