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.

PIC18f4550 EEPROM addressing

Status
Not open for further replies.

Arrowspace

Banned
Joined
Jan 23, 2015
Messages
186
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
0
How can I address EEPROM in PIC18f4550?

Code:
void eeprom_write ( unsigned char data, int address )

If my 1st address is 0 then, what should me my second address to store another char ?
 

You have to pass the next address as the second parameter, for example:
eeprom_write(0x55,0x00); // first address (zero)
eeprom_write(0xAA,0x01); // second address (one)
eeprom_write(0xCC,0x02); // third address (two)

would write 0x55, 0xAA then 0xCC to addresses 0, 1, and 2.

It there is a lot to write, use a variable as the address and increment it in a loop.

Brian.
 

what it is? How you calculated it?

would write 0x55, 0xAA then 0xCC

I have almost 50 variable .
 
Last edited:

The Brian's explanation is very clear.
Please review the post above.
 

You could perform a loop :

Code:
for ( address= 0; address < 50 ; address ++ ) 
{
eeprom_write(address,0x00); // load zero, for instance
}
 

You could perform a loop :

Code:
for ( address= 0; address < 50 ; address ++ ) 
{
eeprom_write(address,0x00); // load zero, for instance
}

All that ok , I understand , but I want to know why 0x55 0xAA and 0xCC are used their?
 

0x55 0xAA and 0xCC are arbitrary data values used by brian to show you how to write data to eeprom. You can replace it with any 1 byte values. What is your start address and end address ? What datas (bytes) you want to write. Which Compiler used ? What crystal frequency ?
 

I general, the first parameter is the data you want to store in the EEPROM and the second parameter is the address you want to store it at. Andre swapped the parameters over in his explanation.

The address doesn't have to be a number in the instruction, it can be a variable. If you use a variable, the value held in the variable will be used as the EEPROM address.
The values I used were just examples, you would use whatever data you wanted to store, either as explicit values or as another variable.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top