Well I found a blunder mistake in the tracks. Following code works perfectly :
#include "mbed.h"
#include "ds3231.h"
#include "_24LCXXX.h"
I2C i2c(PB_11, PB_10);
Serial pc(USBTX, USBRX);
int address = 0x57;
//rtc object
Ds3231 rtc(PB_11, PB_10); //SDA,SCL
_24LCXXX eeprom(&rtc, 0x57);
uint8_t ee_memory[12] = {0,0,1,2,3,4,5,6,7,8,9,10};
uint8_t memory[12] = {0,0,10,20,30,40,50,60,70,80,90,100};
uint8_t read_data[20];
int main()
{
int i,flag;
uint8_t ChkSign;
eeprom.nbyte_read(0, &ChkSign, 1);
pc.printf("Chk Sign! : = %d\n",ChkSign);
if (ChkSign != 21) //Rewrite EEPROM if not found check sign at location '0'
{
ChkSign = 21;
eeprom.byte_write(0, ChkSign); //chk sign value compare which is '21' at loc '0'
for( i=1; i<10; i++)
{
eeprom.byte_write(i, memory[i]);
}
pc.printf("memory byte data write completed!\n");
}
else
{
for(i=1; i<10; i++)
{
eeprom.nbyte_read(i, &memory[i], 1); //Read Backup settings in RTC EEPROM
pc.printf("%d\n",memory[i]);
}
pc.printf("memory byte data read completed!\n");
}
while(1)
{
thread_sleep_for(1000);
}
}
But still not sure why following code with arrays doesn’t work ?
#include "mbed.h"
#include "ds3231.h"
#include "_24LCXXX.h"
I2C i2c(PB_11, PB_10);
Serial pc(USBTX, USBRX);
int address = 0x57;
//rtc object
Ds3231 rtc(PB_11, PB_10); //SDA,SCL
_24LCXXX eeprom(&rtc, 0x57);
uint8_t ee_memory[12] = {0,0,1,2,3,4,5,6,7,8,9,10};
uint8_t memory[12] = {0,0,10,20,30,40,50,60,70,80,90,100};
uint8_t read_data[20];
int main()
{
int i,flag;
uint8_t ChkSign;
eeprom.nbyte_read(ee_memory[0], &ChkSign, 1);
pc.printf("Chk Sign! : = %d\n",ChkSign);
if (ChkSign != 21) //Rewrite EEPROM if not found check sign at location '0'
{
ChkSign = 21;
eeprom.byte_write(ee_memory[0], ChkSign); //chk sign value compare which is '21' at loc '0'
for( i=1; i<10; i++)
{
eeprom.byte_write(ee_memory[i], memory[i]);
}
pc.printf("memory byte data write completed!\n");
}
else
{
for(i=1; i<10; i++)
{
eeprom.nbyte_read(ee_memory[i], &memory[i], 1); //Read Backup settings in RTC EEPROM
pc.printf("%d\n",memory[i]);
}
pc.printf("memory byte data read completed!\n");
}
while(1)
{
thread_sleep_for(1000);
}
}