- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to store permanently 2 variables in the EEPROM.
Currently we have just 1 variable as shown below:
#pragma abs_address 0x1f00 // Start address of block 62 (This device has 64 blocks of 128 bytes)
const int check_variable = 0; // The initial value of the variable
#pragma end_abs_address
...................
volatile char lvd_occurred = FALSE;
#pragma interrupt_handler lvd_handler;
void lvd_handler (void )
{
lvd_occurred = TRUE;
}
void main(void)
{
.............................................
value_for_variable = constant;
if (lvd_occurred != TRUE)
{
bError = E2PROMx128_1_bE2Write(0, (unsigned char *)&value_for_variable, 2, 25);
}
The "constant" value is stored permanently in the EEPROM.
How can we declare and assign a second one?
Many thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Eugenio,
The simplest way that I usually declare multiple variables in EEPROM is to declare a structure (struct) of the data.
Here's an example:
typedef struct
{
uint8 data1; // first data
uint16 data2; // second data
uint32 data3; // third data.
// Add more data if needed.
} ee_data_struct;
// declare the variable in RAM
ee_data_struct ee_data =
{ // Set the default data settings
.data1 = 0x55;
.data2 = 0xFEDC;
.data3 = 0x01234567;
}
/********************************/
void store_EE_data(void)
{
...
// This will write the entire ee_data structure.
bError = E2PROMx128_1_bE2Write(0, (unsigned char *)&ee_data,sizeof(ee_data), 25);
...
}
/********************************/
void main(void)
{
...
// Change ee_data vars.
ee_data.data1 = 0xAA;
...
ee_data.data2 = 0xEDCB;
...
ee_data.data3 = 0x98765432;
...
// Store the ee_data changes in E2PROM.
store_EE_Data();
}
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @Eugenio966
From your description of the issue, I guess you are using an external EEPROM and have interfaced it
with PSoC. Can you please provide more details of the device you are using? Which PSoC device are you using?
How are you communicating with it?
Also provide more information regarding your application (and attach your project if possible) so that we can help with this.
Best Regards
Ekta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ekta,
We are not using any external EEPROM.
it is IC internal EEPROM. We are using CY8C20xx7 devices.
Eugenio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Eugenio,
The simplest way that I usually declare multiple variables in EEPROM is to declare a structure (struct) of the data.
Here's an example:
typedef struct
{
uint8 data1; // first data
uint16 data2; // second data
uint32 data3; // third data.
// Add more data if needed.
} ee_data_struct;
// declare the variable in RAM
ee_data_struct ee_data =
{ // Set the default data settings
.data1 = 0x55;
.data2 = 0xFEDC;
.data3 = 0x01234567;
}
/********************************/
void store_EE_data(void)
{
...
// This will write the entire ee_data structure.
bError = E2PROMx128_1_bE2Write(0, (unsigned char *)&ee_data,sizeof(ee_data), 25);
...
}
/********************************/
void main(void)
{
...
// Change ee_data vars.
ee_data.data1 = 0xAA;
...
ee_data.data2 = 0xEDCB;
...
ee_data.data3 = 0x98765432;
...
// Store the ee_data changes in E2PROM.
store_EE_Data();
}
"Engineering is an Art. The Art of Compromise."