Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Store data time and settings on eeprom

Status
Not open for further replies.

cnandha19

Member level 3
Joined
Aug 28, 2015
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
604
HTML:
    int datetime[5];

    unsinged char lanugage;
 
    void main()
   {
    eeprom_value = 0;
	
	
   spi_eeprom_Write(0x0000,&eeprom_value,sizeof(eeprom_value));
					
   Initialsetup = intilize_initialsetup(Initialsetup);
					
  lcdClear();
  spi_eeprom_Write(0x0001,&Initialsetup.language,sizeof(Initialsetup.language));
  Initialsetup.ChoiceOfLanguage =  spi_eeprom_Read(0x0001);               
     //to store language  how to check whether this setting is stored on not and after turn off and on microcontroller how it will retain 
					
					if(strcmp(Initialsetup.units,Get_Unitsmeterstrings(Initialsetup.ChoiceOfLanguage))==0)
					{
						eeprom_value = 1;
						spi_eeprom_Write(0x0002,&eeprom_value,sizeof(eeprom_value));
					}
					
					if(strcmp(Initialsetup.units,Get_Unitsfeetstrings(Initialsetup.ChoiceOfLanguage))==0)
					{
						eeprom_value = 0;
						spi_eeprom_Write(0x0002,&eeprom_value,sizeof(eeprom_value));
					}
					settime(Initialsetup.datetime[3],Initialsetup.datetime[4]);
					setdate(Initialsetup.datetime[2], Initialsetup.datetime[1], Initialsetup.datetime[0]);
					spi_eeprom_Write(0x0003,Initialsetup.password,sizeof(Initialsetup.password));
				}


I am storing values on eeprom how to check whether this setting is stored on not and after turn off and on microcontroller how it will retain
 

Hi,

I am storing values on eeprom how to check whether this setting is stored on not and after turn off and on microcontroller how it will retain
How to check:
Immediately after you have written the EEPROM cells read them back to verify its contents.

how it will retain:
EEPROM is non volatile memory. It needs no power to keep the contents.
In your software you need a routine to read back the EEPROM values.

**
Hint:
Consider to use something like a checksum or CRC with your EEPROM data, then you are able to check validity of the EEPROM contents after power up.

Klaus
 
Is it correct to write and read to select Language as English in menu drive i have to write "ENGLISH" to EEPROM for that i had done below is it right way to write name and read it on default ascii

Code:
   char store_value;
	unsigned char eeprom_value = 0;
	
    char defaultascii[5];
    char name[10] ={"English"};
	sysclk_init();
	irq_initialize_vectors();
	cpu_irq_enable();
	AT25160B_init();     // SPI  initialization
	initLcd();
	
	lcdClear();
	
	lcdMoveCursor(0,0);
	
	lcdPrintStr("EEPROM TEST");
	
	eeprom_value = 0;
	
	eeprom_value = spi_eeprom_Read(0x0000);
	
	if(eeprom_value != 1)
	{
		spi_eeprom_Write(0x0003, name, sizeof(name));
	}
	
	defaultascii[0] = spi_eeprom_Read(0x0003);
	defaultascii[1] = spi_eeprom_Read(0x0004);
	defaultascii[2] = spi_eeprom_Read(0x0005);
	defaultascii[3] = spi_eeprom_Read(0x0006);
	defaultascii[4] = spi_eeprom_Read(0x0007);
	defaultascii[5] = spi_eeprom_Read(0x0008);	
	
	
	lcdMoveCursor(1,2);
	
	lcdPrintChar(defaultascii[0]);
	
	lcdMoveCursor(1,3);
	
	lcdPrintChar(defaultascii[1]);
	
	lcdMoveCursor(1,4);
	
	lcdPrintChar(defaultascii[2]);
	
	lcdMoveCursor(1,5);
	
	lcdPrintChar(defaultascii[3]);
	
	lcdMoveCursor(1,6);
	
	lcdPrintChar(defaultascii[4]);
	
	lcdMoveCursor(1,7);
	
	lcdPrintChar(defaultascii[5]);
	
	delay_ms(1000);

	
	
}
 

Hi,

What data you store in the EEPROM is completely up to you.

You may store ASCII characters as string like "English".
or you may choose a single byte variable. Where you decide the function upon it´s value. Then 0x00 could represent english language and 0x01 could represent spanish language.

Klaus
 
Code:
if((keyvalue==ENTER)&&(status == 0))
		{
			delay_ms(100);
			
			Initialsetup.datetime[0] = Initialsetup.value_store;
			
			Initialsetup.datetime[0] = Initialsetup.datetime[0] % 100;
			spi_eeprom_Write(0x0022,&Initialsetup.datetime[0],sizeof(Initialsetup.datetime[0]));
			year= Initialsetup.datetime[0];
			
			
			
			
			lcdClear();
			lcdMoveCursor(1,5);
			lcdPrintStr("OK");
			delay_ms(5000);
			read_value = spi_eeprom_Read(0x0022);
			lcdClear();
			lcdMoveCursor(1,5);
		       print_integer(read_value);
			
			delay_ms(5000);


If i read this value means i am getting '0' in LCD display instead of year 2014
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top