Writing 3 bytes data in EEPROM

eeprompic

In pic18f45k80, the datasheet says one can read and write a byte (8bit) data in EEPROM. I need to write 3 bytes data at once and read it back at once because that 3 bytes data consists of two parameters of the lead acid battery which I have to measure. Are there any ways to do this, reading and writing a bulk of data in Pic Microcontroller? An example snippet will be more helpful.

Best Answer

If you're using XC8, include xc.h header file, and use the functions

eeprom_write( addr , data );

and

data = eeprom_read( addr );

So, to write/read 3 bytes, just call these functions three consecutive times, with different addresses each time, of course. There's no way to write/read 3 bytes at once, if that's what you meant.