Discussion in "Project Help" started by    navintiwari08    Apr 12, 2012.
Thu Apr 12 2012, 07:10 PM
#1
hello everyone..
am having problem in writing and reading data from serial eeprom 24c02 interfaced with 8051(P89V51RD2).. please have a look at my program and help me out..
thanks a bunch:)

;-------------------------------------------
; using atmel 24c02 serial eeprom with 8051
;-------------------------------------------
sda equ p2.0
scl equ p2.1

org 00h
sjmp main

org 30h
main:

lcall eeprom_write
lcall eeprom_read
here:
sjmp here


eeprom_start:
setb sda
setb scl
lcall delay
clr sda
lcall delay
clr scl
ret

eeprom_stop:
clr sda
setb scl
lcall delay
setb sda
lcall delay
clr scl
ret

eeprom_write:
lcall eeprom_start
mov a,#0a0h ;device address with write bit
lcall send_data
mov a,#00h ;memory address on device to write to
lcall send_data
mov a,#25h ;data to write on the eeprom
lcall send_data
lcall eeprom_stop
ret

eeprom_read:
lcall eeprom_start
mov a,#0a0h ;device address with write bit(to perform dummy write)
lcall send_data
mov a,#00h ;memory address on device to set the address pointer
lcall send_data
lcall eeprom_start ;repeated start
mov a,#0a1h ;device address with read bit
lcall send_data
lcall get_data ;start reading
lcall eeprom_stop
ret

send_data:
mov r0,#08
loop: clr scl
lcall delay
rlc a
mov sda,c
lcall delay
setb scl
lcall delay
clr scl
djnz r0,loop
setb sda
ack: jb sda,ack ;polling the acknowledge by the device
setb scl
lcall delay
clr scl
ret

get_data:
mov r0,#08
setb sda
nop
loop1:
mov c,sda
setb scl
nop
nop
clr scl
rlc a
djnz r0,loop1
mov p0,a
ret

delay: mov r1,#10
rep: djnz r1,rep
ret

end


[ Edited Thu Apr 12 2012, 07:18 PM ]
Sat Apr 14 2012, 03:01 AM
#2
you have to put delay of atleast 5 to 10 ms after eeprom write to complete the write cycle. I am assuming your I2C is working fine.
Sat Apr 14 2012, 08:28 AM
#3
hello Ajay.. thanx for the reply.. i tried giving it the delay u proposed but it is still not working.. is my program correct? i checked many times but cant spot the error.. pls help. thanks..
Sun Apr 15 2012, 04:43 AM
#4
I dont see any problem the way you are reading from EEPROM but as I said, I am assuming your I2C driver is correct and working fine. You can take i2c reference from tutorial section. and see if everything is alright.
Sun Apr 15 2012, 08:23 AM
#5
thanks a lot Ajay, for the help.. i just solved it.. the 24c02a IC was damaged. i think i burnt it up.. i got a new 24c02 and its working perfectly.. thanks for caring to reply.. have a great day:)
Mon Apr 16 2012, 06:21 PM
#6
thats a good news. keep up the good work. Good Luck!

Get Social

Information

Powered by e107 Forum System

Conversation

Sat Feb 24 2018, 09:05 AM
Aaquib
I want help for digital ic tester
ExperimenterUK
Tue Feb 20 2018, 09:31 PM
Join up.. and post your problem
Mon Feb 19 2018, 04:47 PM
ashishkumar
i needs help for my project
Mon Feb 19 2018, 04:46 PM
ashishkumar
can i join you guys
ExperimenterUK
Mon Feb 05 2018, 03:08 AM
Hi Dave. Good to see you.
DavesGarage
Wed Jan 10 2018, 01:25 AM
It's been a few years since I poked around here - Hi all...
ExperimenterUK
Tue Jan 09 2018, 12:49 AM
Hi TPS. it's been a while..
۞ TPS ۞
Mon Jan 08 2018, 12:12 AM
hello
Thu Jan 04 2018, 07:20 PM
sayyad affrid
its AT89S52
Thu Jan 04 2018, 07:20 PM
sayyad affrid
sir, i want embedded c code for ultrasonic sensor having buzzer interfaced with AT9S52

Downloads

Comments

Manojsanghavi
Sat Feb 24 2018, 12:47 PM
Daro12_76
Wed Feb 21 2018, 05:01 PM
radhikanathani
Wed Feb 21 2018, 06:55 AM
Narayani
Wed Feb 21 2018, 04:10 AM
Parth09
Tue Feb 20 2018, 07:53 AM
goutham
Mon Feb 19 2018, 02:49 AM
kks
Sun Feb 18 2018, 05:59 PM
justotemon
Sat Feb 17 2018, 07:14 AM

Online

Guests: 35, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37971
Newest member: Manojsanghavi
Forum Activity
Manojsanghavi Avatar
Posted By Manojsanghavi
Sat Feb 24 2018, 01:03 PM
Dear allCan someone please help me on how to progr...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 07:10 PM
sbit E = P0^7; //E pin for LCD //use port 0sb...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 02:43 PM
sbit NOT #definesbit E = P0^7; //E pin for LCD ...
Ansh12 Avatar
Posted By Ansh12
Fri Feb 23 2018, 01:55 PM
change your defines tosbit E = P0^7; //E pi...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 23 2018, 01:12 AM
Add pull- ups for EN and RS.change your defines t...
Ansh12 Avatar
Posted By Ansh12
Thu Feb 22 2018, 01:36 AM
Can you post your Proteus files.ExperimenterUKThan...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 09:07 PM
The code you refer to is to drive the circuitshown...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Feb 21 2018, 05:41 PM
Can you post your Proteus files.You will need pull...
radhikanathani Avatar
Posted By radhikanathani
Wed Feb 21 2018, 02:39 PM
I want to design a system for vehicle tracking and...
Narayani Avatar
Posted By Narayani
Wed Feb 21 2018, 04:17 AM
Hello,Your tutorial really helped me understand st...