7 Replies Latest reply on Jun 30, 2014 9:27 PM by ki.leung

    PSOC 4 EEPROM Datasheet Error

    user_14586677

      In the API description the following appears -

         

       

         

      cystatus Em_EEPROM_Write (const uint8 srcBuf[], const uint8 eepromPtr[], uint16/uint32 byteCount)

         

       

         

      This indicates the source buffer must be in code memory, which would not be generally useful.

         

      In fact if the srcBuf[] is declared as a RAM location, not as const, the module works fine. So

         

      this appears to be a datasheet error.

         

       

         

      I have not checked the other datasheets, probably typed with same error.

         

       

         

      Note this is also compounded by GCC after 2.5 (I gather) requiring the _attribute modifier be used

         

      for placing stuff in code memory/FLASH. Which would make the const uint8 eepromPtr[] also typed wrong ?

         

      Even though typed that way it does work. The open source compiler curse in action ?

         

       

         

      Regards, Dana.

        • 1. Re: PSOC 4 EEPROM Datasheet Error
          ki.leung

          For "const"

             

          1. Placing a constant in the parramter of the function, it means the variable passed to the function should not be modified, and the compiler should signal an error/warning if it is being modified.

             

          2.  In the embedd word "const" sometimes also means "code".

          • 2. Re: PSOC 4 EEPROM Datasheet Error
            user_1377889

            @Dana

               

            Despite from PSoC1 ImageCraft compiler where a const parameter is expected to be in flash, a const parameter in GCC will not be allowed to be altered by the compiler (there are tricks to circumvent that using pointers).

               

             

               

            For GCC applies:

               

            A variable definition preceded by the keyword "const" will be located in flash as long as the variable is initialized together with the declaration.

               

             

               

            Too many compilers, too many exceptions. Why not a new keyword for Harvard-architectures "flash" or something similar. The approach with __attribute__ and/or some linker instructions is not portable, too.

               

             

               

            Bob

            • 3. Re: PSOC 4 EEPROM Datasheet Error
              user_14586677

              Bob, is that the differentiator for flash placement in GCC after 2.5 ?,

                 

              as you stated -

                 

               

                 

              A variable definition preceded by the keyword "const" will be located in flash as long as the variable is initialized together with the declaration.

                 

               

                 

              Regards, Dana.

              • 4. Re: PSOC 4 EEPROM Datasheet Error
                user_1377889

                Latest GCC manuals are from 2.95 on kept here gcc.gnu.org/onlinedocs/, so I don't know when the Havard-"const" declaration was introduced, but I think it was in 4.

                   

                Additionally see your own post here www.cypress.com/ near the end of the thread, which specifies the need for initialization.

                   

                 

                   

                Bob

                • 5. Re: PSOC 4 EEPROM Datasheet Error
                  yfs

                  In C, the const keyword is a mess! I love using the language but have to admit that "const int" meaning the same thing as "int const" is a bit naughty. That said, it could be worse. I have been doing things with XML recently (first time) and whoever came up with "<!--" and "-->" for comments deserves a poke in the eye with a very sharp stick. Or they should be made to be an England football supporter, whichever is more painful (I'm not sure). May have gone off-topic there...

                     

                  The const keyword will only cause static variables to be placed in ROM areas (and they must be initialized). In practice that applies to globals and locals that are declared explicitly static. It does not apply to automatics (which includes function arguments). The Em_EEPROM_Write function declaration is saying that the contents of the array are not modifed, not that they are, or must be, in ROM. It's just being friendly!

                     

                  -- Mark.

                  • 6. Re: PSOC 4 EEPROM Datasheet Error
                    user_14586677

                    Thanks, my quest for consistency has been shelved :)

                       

                     

                       

                    Regards, Dana.

                    • 7. Re: PSOC 4 EEPROM Datasheet Error
                      ki.leung

                      The Only Thing That Is Constant Is Change -’