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 May 28 2016, 04:34 PM
kibrom berhe
c code for locker security system based on rfid and gsm
ExperimenterUK
Wed May 25 2016, 05:05 AM
@ Ramanjaneyulu, post in forum,explain your problem
Mon May 23 2016, 11:34 PM
Ramanjaneyulu
Hi, I Am using at89c4051 for my application, I want 5u sec dely.. Up to 1milli sec iam able to producing delay. Beyond the 1milli second, I am unable to produce the acceurate dely. Plz any one help me
Sat May 21 2016, 09:51 PM
A K
i want to mak an auto dialer using gsm and atmega 16. please helpe me how to write a code to auto dial a number saved in sim
Sat May 21 2016, 10:42 AM
Alec
Hi im trying to program my 89s51 with a usbasp so any ideas on the circuit?
Wed May 18 2016, 10:08 AM
Tashu joshi
anyone know how to develop
Wed May 18 2016, 10:07 AM
Tashu joshi
i'm working for resporatry system using 8051,
Wed May 18 2016, 10:06 AM
Tashu joshi
i'm developing a respiratory system using Arduino
Fri May 13 2016, 11:03 AM
MEGHANA
i need c code for counting frequency of two sensors and compare these frequencies and it has to give high/ low signal after comparision
ExperimenterUK
Tue May 10 2016, 05:02 PM
@Suren ..create a thread in the 8051 Discussion Forum to discuss your problem

Downloads

Comments

zaft93
Sun May 15 2016, 01:52 AM
CELEBI
Thu May 12 2016, 08:28 AM
Suro1996
Wed May 11 2016, 06:07 PM
yigithan
Sat May 07 2016, 09:09 PM
jaque
Fri May 06 2016, 07:51 PM
afzal42
Wed May 04 2016, 11:16 AM
pd
Sun May 01 2016, 01:35 AM
uk2308
Fri Apr 29 2016, 12:27 PM

Online

Guests: 40, Members: 0 ...

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

Members: 37765
Newest member: zaft93
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun May 15 2016, 10:58 PM
zaft93 Avatar
Posted By zaft93
Sun May 15 2016, 01:55 AM
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri May 13 2016, 07:59 PM
If you want only one relay to be on at a time the ...
CELEBI Avatar
Posted By CELEBI
Fri May 13 2016, 06:16 AM
Yes. It must be as you said. It must be 1.5 second...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 12 2016, 08:35 PM
Here is one way.If you have the Keil compiler you ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 12 2016, 05:20 PM
Sorry I don't understand what you want.Is that 1.5...
CELEBI Avatar
Posted By CELEBI
Thu May 12 2016, 08:53 AM
Hello Guys, I want to make a Project with 89s51 bu...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed May 11 2016, 09:28 PM
No this is all I've got, the algorithm I think is ...
Suro1996 Avatar
Posted By Suro1996
Wed May 11 2016, 09:27 PM
Is this all the code you have ?As it is, it will n...
Suro1996 Avatar
Posted By Suro1996
Wed May 11 2016, 07:31 PM
Hello, I am new to assembly programming and I am h...