- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Community,
How do I exactly use the EEPROM module?
When I search the internet I find some tutorials which use functions like Eeprom_WriteByte; Emprom_ReadByte but in my build there are no such functions at all (the tutorial use 5lp prototyping kit controller, like me though).
What I have is the function Eeprom_Write.
But I do not really understand what this function expect me to put in.
This is what the datasheet says:
Em_EEPROM_Write (const uint8 srcBuf[], const uint8 eepromPtr[], uint16/uint32 byteCount)
Is the srcBuff[] a pointer to the information I want to save in the Eeprom?
Is the eepromPtr[] a pointer to the location of the EEProm?
If this is true how can I define the location of EEProm or how can determinate this location?
How can I read the stored Data.
Sorry if I did unstand it completely wrong, but the datasheet looks pretty cryptic to me.
Solved! Go to Solution.
- Labels:
-
PSoC 5 Device Programming
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC 5LP has two different components; the EEPROM component and the Emulated EEPROM component. The EEPROM component provides set of APIs to erase and write to non-volatile on-chip EEPROM memory. Whereas, the Emulated EEPROM component emulates an EEPROM device in the PSoC device flash memory. EEPROM_WriteByte and Em_EEPROM_Write are write API interfaces to EEPROM and Emulated EEPROM components respectively.
Please refer to PSoC Creator provided code examples to understand component usage. Please go to File > Code Example for EEPROM_Design and PSoC_EmEEPROM_PSoC5 code examples.
If you are using Em_EEPROM is your application, use EmEEPROM_Read (uint32 addr, void * eepromData, uint32 size) to read size units of data from logical address addr and write to array pointer eepromData. Please refer to Em_EEPROM component datasheet for more details on API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ivankatzer,
If you want to simply save/read some parameters into EEPROM, use example project and custom coomponent that does just that:
myEEPROM: component to save/recall application settings in EEPROM between power offs
For details of EEPROM access look into the myEEPROM component's API code.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Let me add my sample, too 😉
Schematic
main.c
===========================
#include "project.h"
#include "stdio.h"
char str[128] ; /* print buffer */
void print(char *str)
{
UART_PutString(str) ;
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
EEPROM_Start() ;
EEPROM_UpdateTemperature() ;
}
void splash(void)
{
sprintf(str, "EEPROM Test (%s %s)\n", __DATE__, __TIME__) ;
print(str) ;
}
int main(void)
{
unsigned int i ;
int erase_after_test = 0 ; // if you want to clear EEPROM after test, set this to 1
init_hardware() ;
splash() ;
sprintf(str, "EEPROM Size = %d\n", CY_EEPROM_SIZE) ;
print(str) ;
print("EEPROM Current Contents\n") ;
for (i = 0 ; i < 0x100 ; i++ ) { /* show only the first 256 bytes */
sprintf(str, "%02X ", EEPROM_ReadByte(i)) ;
print(str) ;
if (((i + 1) % 0x10) == 0) {
print("\n") ;
}
}
print("\n") ;
print("Updating data ... \n") ;
if (EEPROM_ReadByte(0) == 0) {
for (i = 0 ; i < 0x100 ; i++ ) {
EEPROM_WriteByte(0xFF - i, i ) ;
}
} else {
for (i = 0 ; i < 0x100 ; i++ ) {
EEPROM_WriteByte(i, i) ;
}
}
print("Done\n") ;
print("EEPROM Updated Contents\n") ;
for (i = 0 ; i < 0x100 ; i++ ) { /* show only the first 256 bytes */
sprintf(str, "%02X ", EEPROM_ReadByte(i)) ;
print(str) ;
if (((i + 1) % 0x10) == 0) {
print("\n") ;
}
}
print("\n") ;
if (erase_after_test) {
EEPROM_EraseSector(0) ;
if (EEPROM_Query() != CYRET_SUCCESS) {
print("Erasing EEPROM Sector 0 failed\n") ;
}
print("EEPROM Contents after erase\n") ;
for (i = 0 ; i < 0x100 ; i++ ) { /* show only the first 256 bytes */
sprintf(str, "%02X ", EEPROM_ReadByte(i)) ;
print(str) ;
if (((i + 1) % 0x10) == 0) {
print("\n") ;
}
}
print("\n") ;
}
for(;;)
{
/* Place your application code here. */
}
}
===========================
TeraTerm log
Note: If the first byte is 0, the update data from 0xFF to 0x00
else update data from 0x00 to 0xFF.
If you set the variable "erase_after_test" non zero value,
EEPROM will be erased after test.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC 5LP has two different components; the EEPROM component and the Emulated EEPROM component. The EEPROM component provides set of APIs to erase and write to non-volatile on-chip EEPROM memory. Whereas, the Emulated EEPROM component emulates an EEPROM device in the PSoC device flash memory. EEPROM_WriteByte and Em_EEPROM_Write are write API interfaces to EEPROM and Emulated EEPROM components respectively.
Please refer to PSoC Creator provided code examples to understand component usage. Please go to File > Code Example for EEPROM_Design and PSoC_EmEEPROM_PSoC5 code examples.
If you are using Em_EEPROM is your application, use EmEEPROM_Read (uint32 addr, void * eepromData, uint32 size) to read size units of data from logical address addr and write to array pointer eepromData. Please refer to Em_EEPROM component datasheet for more details on API.