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

ExperimenterUK
Fri Feb 12 2016, 04:39 AM
@ Ankush SS .. source code for what?
plinniocom2n
Fri Feb 12 2016, 12:17 AM
thank you
Tue Feb 09 2016, 05:17 PM
Ankush SS
Can i get the source code of this project? Please n thnk u for ur kindness
Fri Feb 05 2016, 08:33 AM
SANJYOT JADHAV
sir did we have to use Gsm modem for testing the circuit on proteus
Tue Feb 02 2016, 11:17 AM
upendra kumar
i want information about 3-phase motor control using gsm technology
Sat Jan 16 2016, 05:33 PM
Kenneth Etuk
Hi everyone, I need help with a project involving MCU,rttc, and DC motor. I will pay for it. please reply to my mail [email protected] if you are interested. thanks
ExperimenterUK
Sat Jan 16 2016, 02:08 AM
@Kabona Log in and create a thread. Tell us what you want to do
Tue Jan 12 2016, 08:24 PM
Kabona
how can I make my pc be input and output device for the microcontroller
Sat Jan 09 2016, 07:04 AM
Ravz
Thank u..... one more doubt Will ultrasonic sensor HC-SR04 works with aurdino board in operating system linux
Tommy.Kofisterix
Fri Jan 08 2016, 08:50 PM
I know it detects also the mud on rear bumper, this means other obstacles will

Downloads

Comments

plinniocom2n
Fri Feb 12 2016, 12:12 AM
designAAA
Sat Jan 30 2016, 08:49 AM
syavash_kasraeee
Sat Jan 16 2016, 05:54 AM
hamudi
Thu Jan 07 2016, 04:40 AM
Spandan89
Tue Jan 05 2016, 04:06 PM
siimao
Thu Dec 24 2015, 04:00 PM
moinabbasqureshi
Thu Dec 17 2015, 03:35 PM
dodo
Tue Dec 15 2015, 11:36 AM

Online

Guests: 52, Members: 0 ...

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

Members: 37728
Newest member: plinniocom2n
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 12 2016, 11:04 PM
Try this program.Let me know if it makes sense to ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 12 2016, 04:45 AM
How do I get the link to the file? plinniocom2nGoo...
plinniocom2n Avatar
Posted By plinniocom2n
Fri Feb 12 2016, 12:18 AM
How do I get the link to the file? Newbie here.
sankalp_s Avatar
Posted By sankalp_s
Thu Feb 11 2016, 06:28 PM
Hello phil sir finaly i'm dumping my code, now i'm...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Feb 04 2016, 04:10 AM
Sir I didn't understand that. Could you explain ab...
sankalp_s Avatar
Posted By sankalp_s
Tue Feb 02 2016, 07:26 PM
but good use of sub routines will save a lot of ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Feb 02 2016, 12:25 AM
after removing ALLON instruction it's working fine...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Feb 02 2016, 12:14 AM
Which micro controller are you using ?.Does it hav...
sankalp_s Avatar
Posted By sankalp_s
Sat Jan 30 2016, 07:40 PM
You need to explain exactly what you want the code...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Jan 30 2016, 06:57 PM
>sir can you code this in any other method?You nee...