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] EEPROM read and WRITE program, pls check it.

Status
Not open for further replies.

vinodstanur

Advanced Member level 3
Joined
Oct 31, 2009
Messages
751
Helped
114
Reputation
234
Reaction score
114
Trophy points
1,333
Location
Kerala (INDIA)
Activity points
7,054
#include <htc.h>
#define _XTAL_FREQ 4e6 // 4MHz
__CONFIG(0x3F3A);
void write(int k)
{
EEADR=1;
EEDATA=k;
EEPGD=0;
WREN=1;
EECON2=0x55;
EECON2=0xAA;
WR=1;
WREN=0;EEDATA=0;
}

void main()
{int d;
TRISB=0;TRISD=0xFF;
EEADR=1;
EEPGD=0;
RD=1;d=EEDATA;
if(d==0xF0){while(1){PORTB=255;if(RD3==1){write(10);}};}
write(0xF0);write(0xF0);
while(1)
{__delay_ms(10);
EEADR=1;
EEPGD=0;
RD=1;d=EEDATA;
PORTB=d;
}
}

this is my test program ;
here, when the pic is inserted to the circuit, then port b shows F0h.
then if i reset the pic then PORTB becomes FFh.
this much is correct ....
but,
when i give RD3=1 and then I reset the PIC, then PORTB is not becoming F0h.
it shows 00H....
why?
could any one help me?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top