PSOC 4 EEPROM Datasheet Error

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

cross mob
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
7 Replies
Anonymous
Not applicable

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".

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@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

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
markgsaunders
Employee
Employee
50 sign-ins 10 solutions authored 5 solutions authored

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.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Thanks, my quest for consistency has been shelved 🙂

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

The Only Thing That Is Constant Is Change -’

0 Likes