• 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 Read/Write

Status
Not open for further replies.

TucsonDon

Member
I am using MPLab and MCC on a PIC18F45K22. My question is if I write a float to the eeprom will the address counter increment itself for the four bytes or will I need to use a for loop and advance the address counter?
 

dknguyen

Well-Known Member
Most Helpful Member
The datasheet doesn't say?

I wish my ARM had an EEPROM. I'm scared of simulating EEPROM using the flash because that's where the program also is lol
 

dknguyen

Well-Known Member
Most Helpful Member
Well, you could test just by writing something, and reading the address register to see if it's the same as what it was before and lighting up an LED if it is.

I would think it doesn't auto-increment though since I also did not see it anywhere in the datasheet where I would have expected to see it.
 

dknguyen

Well-Known Member
Most Helpful Member
It's just you :D

There's only a single write there, the 0x55 and 0xAA are simply to make the write happen.
Yeah I just noticed that was a unlocking sequence. I thought it was weird they overwrote the same thing to the register and then set the WR bit.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
To answer you question !!

To store a float is easier if you serialise it... A float is 4 bytes so

union{
float x;
unsigned char serialise[4];​
} storefloat;

// writing
for(x = 0;x<4;x++){
writeeeprom(x, storefloat.serialise[x];
eepromwritedelay();​
}

// reading
for(x = 0;x<4;x++){
storefloat.serialise[x] = readeeprom(x );​
}
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Sorry! I misread the OP... I see what you mean... You want to write all the bytes in one go..

Normally serial eeproms have a "Housekeeping" which means if the eeprom supports page writes an entire page may be written to a scratchpad ( sram) and transferred internally... I do not think the inbuilt EEprom supports page writes on a PIC... So single write may be the only option..
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top