- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Spent a lot of time trying to understand where is the BUG.
The reason is, if you do not really fill EEPROM array with definite values, it does not work, returning CYRET_BAD_PARAM.
Say, if you declare EEPROM array as
static const uint8 CYCODE eepromArray[8];
you will not be able to perform EEPROM_Write.
You have to fill it with any values.
static const uint8 CYCODE eepromArray[8]= {0, 0, 0, 0, 0, 0, 0, 0};
then it will work.
IMHO, it MUST be mentioned in the manual.
Tested only with PSoC 4.
Example to test:
int main()
{
uint8 t[8]={1,2,3,4,5,6,7,8};
cystatus status;
static const uint8 CYCODE eepromArray[8]= {8, 7, 6, 5, 4, 3, 2, 0};
static const uint8 CYCODE eepromArray1[8]= {0, 0, 0, 0, 0, 0, 0, 0};
static const uint8 CYCODE eepromArray2[8];
Em_EEPROM_Start();
status = Em_EEPROM_Write(t, eepromArray,8u); // OK
if (CYRET_SUCCESS != status){
SW_Tx_UART_PutString("Em EEPROM error\n\r");
}
status = Em_EEPROM_Write(t, eepromArray1,8u); // OK
if (CYRET_SUCCESS != status){
SW_Tx_UART_PutString("Em1 EEPROM error\n\r");
}
status = Em_EEPROM_Write(t, eepromArray2,8u);
if (CYRET_SUCCESS != status){
SW_Tx_UART_PutString("Em2 EEPROM error\n\r"); // you'll get this error
}
while(1);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kabron,
If you read carefully the corresponding component datasheet (V1.10A) page 4 of the pdf document:
"In order to force the compiler to locate data in Flash, variables/arrays should be declared as “static const (CYCODE for PSoC 3)” and initialized with some value at the same time. Reads from Flash are recommended to be done using “(volatile)” type qualifier to prevent the compiler from optimizing reads from static variables. For details on component usage please refer to Emulated EEPROM example project."
So Cypress has already answered your request 🙂
Happy New Year,
Michel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kabron,
If you read carefully the corresponding component datasheet (V1.10A) page 4 of the pdf document:
"In order to force the compiler to locate data in Flash, variables/arrays should be declared as “static const (CYCODE for PSoC 3)” and initialized with some value at the same time. Reads from Flash are recommended to be done using “(volatile)” type qualifier to prevent the compiler from optimizing reads from static variables. For details on component usage please refer to Emulated EEPROM example project."
So Cypress has already answered your request 🙂
Happy New Year,
Michel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I was not attentive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is another pitfall: Under some circumstances the compiler "remembers" that the values are "const" and when accessing the flash data. it inserts the known const value instead of actually reading the values. I used a memcpy() to overcome that.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, I noticed it a couple of times.