Discussion in "Project Help" started by    navintiwari08    Apr 12, 2012.
Thu Apr 12 2012, 03: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, 03:18 PM ]
Fri Apr 13 2012, 11:01 PM
#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, 04: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, 12: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, 04: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, 02:21 PM
#6
thats a good news. keep up the good work. Good Luck!

Get Social

Information

Powered by e107 Forum System

Conversation

Mon Aug 25 2014, 07:12 AM
Vinod Soni
Hi Sir, How can i make this RFID with ATMega16/32 controller
pavanjain
Sat Aug 23 2014, 05:10 AM
Sir i want to download the hex file in P89v51rd2 microcontroller using max232 IC but we not load the program in IC
Tue Aug 19 2014, 04:51 PM
allen ndumu
please i will like to know if the problem of speed control of dc motor using keypad and l298 was if yes can i have the complete project send it to the address i really need to see it
Tue Aug 19 2014, 10:47 AM
Amit Bisht
sir i want to have some trending projects on which i could work related to ATmega 16 microcontroller
ExperimenterUK
Sat Aug 16 2014, 04:16 PM
@diligent . create a thread
Sat Aug 16 2014, 03:17 PM
diligent
in assembly langauage programming..
Sat Aug 16 2014, 03:14 PM
diligent
will anyone help me?
Thu Aug 14 2014, 10:24 PM
Amirudin Tone
i help, i need liberary IC 4047 in the proteus. thanks
ExperimenterUK
Thu Aug 14 2014, 03:59 PM
@NARAYANA are you getting an error ?
Tue Aug 12 2014, 11:47 PM
NARAYANA
i am not able to get reg please provide me registration link

Downloads

Comments

sadalakshmi
Wed Aug 27 2014, 12:39 AM
Paecake
Sun Aug 24 2014, 04:07 PM
pavanjain
Sat Aug 23 2014, 02:33 AM
samchovatiya
Thu Aug 21 2014, 02:30 PM
hasmukhjain
Wed Aug 20 2014, 06:28 AM
rablo
Tue Aug 19 2014, 10:10 AM
faizhameed
Tue Aug 12 2014, 10:39 PM
ind3siszive
Sun Aug 10 2014, 01:05 PM

Online

Guests: 55, Members: 0 ...

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

Members: 37500
Newest member: sadalakshmi
Forum Activity
siddique Avatar
Posted By siddique
Wed Aug 27 2014, 01:48 AM
Pls check the Tx and Rx functions have made some c...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Aug 26 2014, 06:03 PM
I assume you have made the changes I suggested to ...
siddique Avatar
Posted By siddique
Tue Aug 26 2014, 03:20 AM
Hi,Tried your suggestions.when i put the device in...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 25 2014, 04:00 PM
This tutorial looks useful.http://www.diyembedded....
siddique Avatar
Posted By siddique
Mon Aug 25 2014, 03:30 AM
Hi,I'm currently working on the nRF24L01+ transcei...
gaurav7577 Avatar
Posted By gaurav7577
Mon Aug 25 2014, 12:38 AM
Code which is already loaded is running fine...but...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Aug 24 2014, 03:32 PM
thnks for rply..i hav attached error pic here...pl...
gaurav7577 Avatar
Posted By gaurav7577
Fri Aug 22 2014, 01:30 AM
thnks for rply..i hav attached error pic here...pl...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Aug 22 2014, 12:46 AM
It is clearly mention with segment name on the pin...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Aug 22 2014, 12:42 AM
What is the error that you're getting?