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.

[SOLVED] My EEPROM read function does not work on 16F876A internal EEPROM?

Status
Not open for further replies.

hamed8419215

Member level 5
Joined
Mar 3, 2010
Messages
86
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,298
Location
mashhad
Activity points
1,795
Hi to all (Salam)
I want to read from internal EEPROM of a PIC16F876A.
I wrote a function for read and also a function to write.
The write function works fine but the read function does not work.
these are my functions (In mikroC PRO):
//---------Read EEPROM--------//
char ReadEEPROM(char EEReadAddress)
{
EEADR=EEReadAddress;
EEPGD_bit=0;
RD_bit=0;
asm nop;
return(EEDATA);
}
//--------Write EEPROM--------//
void WriteEEPROM(char EEWriteAddress, char EEPROMData)
{
EEADR=EEWriteAddress;
EEDATA=EEPROMData;
EEPGD_bit=0;
WREN_bit=1;
EECON2=0x55;
EECON2=0xAA;
WR_bit=1;
WREN_bit=0;
while(WR_bit)
{
asm nop;
}
}
I wrote these function just like PIC16F87xA data sheet.
I also debug it with Proteus. in read function EEADR always filled with 0xA1 not with EEReadAddress.:?
 

Opps! a little bug with big bad result!
I change my code. read function also works fine, but in Proteus EEADR always have 0xA1?
(Thank you very much).

---------- Post added at 18:00 ---------- Previous post was at 17:54 ----------

My problem solved totally.
thanks a lot.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top