Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

EEprom - Reading and Writing

Status
Not open for further replies.

Wp100

Well-Known Member
Hi,

Something I could do easily in Pic Assembly code but cannot see if it can be done with C++ ..?

I am declaring a series of control parameters at the beginning of the code, all as single Bytes. eg, temp, timehours, timemins, etc
I want to be able to store them all in eeprom in one go rather than individually ; as most Arduino examples show.
During program run these values may be changed, so when the program is restarted, then it will read out the updated eeprom block of Bytes and restore them.

Is this possible ?

thanks
 
Do you not want to use the "two wire" library??? The Arduino IDE has this library already!!
This is his wish:
"I want to be able to store them all in eeprom in one go rather than individually ; as most Arduino examples show."
We have to put this request to Atmel.
 
Do you not want to use the "two wire" library??? The Arduino IDE has this library already!!
Hi,

Sorry, should have said Save to Internal EEprom.

As Zahwi shows, its how can I several Byte variables be saved and restored from eeprom in one operation rather than calling each one by name; probably about 40 Bytes when the program finished.

Eg
byte LEDPWM_VALUE = 0;
byte LEDPWM_PRELOAD = 30;
byte LEDPWM_INCVALUE = 5;
byte LEDPWM_INCTIME = 3;
byte LEDPWM_DAY = 0;
byte LEDPWM_MOON = 50;



Zahwi - do not think Atmel will be interested in an Arduino / C++ problem ...?
 
Writing to eeprom is limited to about 1 million cycles. It takes several instructions in certain order. It takes about 5ms to write 1 byte. Microcontrollers don't have the option of writing more than 1 byte at a time.
If you need to update the data often then write it to the RAM and only periodically copy it to the eeprom when the CPU isn't busy.
 
You do it in C exactly the same way as in asm. What have you tried that didn't work?

Mike.
 
You do it in C exactly the same way as in asm. What have you tried that didn't work?

Mike.

Hi,

All I can find for writing to EEprom is this Write out a single byte variable " EEPROM.write(addr, val);"

I have 40+ Byte Variables as showing in entry #4.

So with that instruction I have to code a EErpom.Write for each variable.

I was hoping to find some way of indetifying the whole block of byte variables and code it in one function ?
 
Make a table that contains the addresses of the variables and then use a for loop to read/write them. To find the address use the & form. I.E &LEDPWM_VALUE will give the address of LEDPWM_VALUE.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top