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 ?
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
15,598
Helped
5,041
Reputation
10,106
Reaction score
4,886
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
132,212
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.
 

Arrowspace

Banned
Joined
Jan 23, 2015
Messages
186
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
0
what it is? How you calculated it?

would write 0x55, 0xAA then 0xCC

I have almost 50 variable .
 
Last edited:

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,418
Helped
1,175
Reputation
2,369
Reaction score
1,169
Trophy points
1,403
Location
Brazil
Activity points
54,764
The Brian's explanation is very clear.
Please review the post above.
 

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,418
Helped
1,175
Reputation
2,369
Reaction score
1,169
Trophy points
1,403
Location
Brazil
Activity points
54,764
You could perform a loop :

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

Arrowspace

Banned
Joined
Jan 23, 2015
Messages
186
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
0
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?
 

pic.programmer

Advanced Member level 3
Joined
Aug 19, 2015
Messages
773
Helped
141
Reputation
284
Reaction score
140
Trophy points
43
Activity points
7,531
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 ?
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
15,598
Helped
5,041
Reputation
10,106
Reaction score
4,886
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
132,212
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

Top