eeprom8  2.0.0.0
Main Page

EEPROM 8 click

EEPROM 8 Click is a compact add-on board that contains a highly reliable nonvolatile memory solution. This board features the CAV24C512, a 512-Kb electrically erasable programmable memory with enhanced hardware write protection for entire memory from ON Semiconductor. Internally organized as 65,536 words of 8 bits each, the CAV24C512 comes up with the compatible I2C serial interface. The CAV24C512 combines unprecedented data storage with excellent energy efficiency. It lasts one million full-memory read/write/erase cycles with more than 100 years of data retention.

click Product page


Click library

  • Author : Stefan Popovic
  • Date : Mar 2022.
  • Type : I2C type

Software Support

We provide a library for the EEPROM 8 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for EEPROM 8 Click driver.

Standard key functions :

Example key functions :

  • eeprom8_write_page This function writes up to 128 bytes of data starting from the selected register.
    err_t eeprom8_write_page( eeprom8_t *ctx, uint16_t reg_addr, uint8_t *data_in );
  • eeprom8_read_random_byte This function reads one byte data from the desired register.
    err_t eeprom8_read_random_byte( eeprom8_t *ctx, uint16_t reg_addr, uint8_t *data_out );
  • eeprom8_read_sequential This function reads the desired number of bytes starting from the selected register.
    err_t eeprom8_read_sequential( eeprom8_t *ctx, uint16_t reg_addr, uint16_t n_bytes, uint8_t *data_out );

Example Description

This example demonstrates the use of EEPROM 8 click board by writing specified data to the memory and reading it back.

The demo application is composed of two sections :

Application Init

Initializes the driver and USB UART logging.

void application_init ( void )
{
eeprom8_cfg_t eeprom8_cfg;
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
eeprom8_cfg_setup( &eeprom8_cfg );
EEPROM8_MAP_MIKROBUS( eeprom8_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == eeprom8_init( &eeprom8, &eeprom8_cfg ) )
{
log_error( &logger, " Communication Init " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Task writes a desired number of data bytes to the EEPROM 8 memory and verifies that it is written correctly by reading from the same memory location and in case of successful read, displays the memory content on the USB UART. This is done in two passes.

void application_task ( void )
{
// Reset variables
cnt = 0;
memset( test_read_buffer, 0, sizeof ( test_read_buffer ) );
addr_offset = TEST_MEM_LOCATION;
// Initiate first pass
// filling the eeprom addresses with zeros
if( EEPROM8_ERROR == run_first_pass( &eeprom8, test_write_buffer, test_read_buffer ) )
{
log_error( &logger, " First Pass Failed " );
}
// Initiate second pass
// filling the eeprom addresses with values following arithmetic sequence with difference of 1
if( EEPROM8_ERROR == run_second_pass( &eeprom8, test_write_buffer, test_read_buffer ) )
{
log_error( &logger, " Second Pass Failed " );
}
log_printf( &logger, " \r\nInitiating new iteration\r\n " );
Delay_ms( 6000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.EEPROM8

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


run_second_pass
err_t run_second_pass(eeprom8_t *ctx, uint8_t *write_buf, uint8_t *read_buf)
Second pass function.
Definition: main.c:198
eeprom8_t
EEPROM 8 Click context object.
Definition: eeprom8.h:142
EEPROM8_MAP_MIKROBUS
#define EEPROM8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: eeprom8.h:111
eeprom8_write_page
err_t eeprom8_write_page(eeprom8_t *ctx, uint16_t reg_addr, uint8_t *data_in)
Page Write function.
eeprom8_read_random_byte
err_t eeprom8_read_random_byte(eeprom8_t *ctx, uint16_t reg_addr, uint8_t *data_out)
Random Byte Read function.
application_task
void application_task(void)
Definition: main.c:100
EEPROM8_ERROR
@ EEPROM8_ERROR
Definition: eeprom8.h:177
eeprom8_read_sequential
err_t eeprom8_read_sequential(eeprom8_t *ctx, uint16_t reg_addr, uint16_t n_bytes, uint8_t *data_out)
Sequential Read function.
TEST_MEM_LOCATION
#define TEST_MEM_LOCATION
Definition: main.c:35
eeprom8_cfg_t
EEPROM 8 Click configuration object.
Definition: eeprom8.h:159
application_init
void application_init(void)
Definition: main.c:70
run_first_pass
err_t run_first_pass(eeprom8_t *ctx, uint8_t *write_buf, uint8_t *read_buf)
First pass function.
Definition: main.c:136
eeprom8_cfg_setup
void eeprom8_cfg_setup(eeprom8_cfg_t *cfg)
EEPROM 8 configuration object setup function.
eeprom8_init
err_t eeprom8_init(eeprom8_t *ctx, eeprom8_cfg_t *cfg)
EEPROM 8 initialization function.