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
Forum Activity
pravin_35 Avatar
Posted By pravin_35
Thu Jul 31 2014, 01:49 AM
attach is the code for lcd may be need a little ch...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:45 PM
@ sermeteraythank you for sharing your experience ...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:38 PM
@ Peter_ParkerHC06 by default baud rate is 9600try...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:25 PM
attach is the code for lcd may be need a little ch...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:21 PM
@ pravin_35both compilers are almost sameif you ha...
pravin_35 Avatar
Posted By pravin_35
Wed Jul 30 2014, 07:38 AM
http://extremeelectronics.co.in/pic16f877a-tutoria...
NexusRevZ Avatar
Posted By NexusRevZ
Wed Jul 30 2014, 02:31 AM
Ok, I have edited the code, it's updated above wit...
NexusRevZ Avatar
Posted By NexusRevZ
Wed Jul 30 2014, 02:10 AM
Oh tahnk you so much for the reply. I will do imme...
ajay_bhargav Avatar
Posted By ajay_bhargav
Wed Jul 30 2014, 01:56 AM
You cannot move and read data from EEPROM immediat...
pravin_35 Avatar
Posted By pravin_35
Wed Jul 30 2014, 12:39 AM
Remove all power connections to the circuit at the...

Conversation

NexusRevZ
Tue Jul 29 2014, 09:32 PM
Anyone good in Asm lang?
ajay_bhargav
Mon Jul 28 2014, 12:34 AM
@ Anshu Raj sorry we do not take such requests.
Sun Jul 27 2014, 12:23 AM
Anshu Raj
sir plz send the automatic collage alram bells in 2 hrs bells ring. For microcontroller programme plz sir
ajay_bhargav
Thu Jul 24 2014, 01:06 AM
@R.ABHISHEK where? I dont see it. is it in forum?
Wed Jul 23 2014, 05:49 AM
R.ABHISHEK
sir,pls message on microcontroller 8051 assambly language new program
Wed Jul 23 2014, 05:47 AM
R.ABHISHEK
sir,pls message on 8051 microcontroller assambly language program new quastions
ajay_bhargav
Tue Jul 22 2014, 09:18 AM
@Pragya Android application is taken from google play. Only Author has its source with him. Application is only used in this project.
Tue Jul 22 2014, 04:58 AM
Pragya
plz send me 8051 code and android code for android based device controller via Bluetooth .Here in this project I am using Hc-06 Bluetooth module
Thu Jul 10 2014, 09:57 AM
Caleb
plz someone mail me the source code for that project
Thu Jul 10 2014, 09:57 AM
Caleb
http://www.8051projects.net/download-d188-control-your-pc-tv-remote.html

Downloads

Comments

NexusRevZ
Tue Jul 29 2014, 09:29 PM
kritz22
Mon Jul 28 2014, 10:33 AM
Abbasans786
Mon Jul 28 2014, 03:15 AM
Imran.pk
Fri Jul 25 2014, 07:50 PM
PavanKh
Fri Jul 25 2014, 12:56 AM
vinosentinal
Mon Jul 21 2014, 08:28 PM
niks_here
Sun Jul 20 2014, 05:38 PM
athiramsankar
Sun Jul 20 2014, 12:00 PM

Online

Guests: 39, Members: 0 ...

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

Members: 37484
Newest member: NexusRevZ