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
Sat Sep 13 2014, 04:34 PM
jaimin1212,Pimpalkhare Create a thread for your question
jaimin1212
Sat Sep 13 2014, 06:35 AM
i want to make self balancing robot using MPU6050 using atmega8.. please help to get data of gyro and accelerometer from this sensor through atmega8.
Thu Sep 11 2014, 01:00 PM
Sunil Pimpalkhare
Hello sir, I am trying to make Wearfin project https://www.youtube.com/watch?v=iZ6PVBvQf-g so can u help me in teaching how to built the program???
Thu Sep 11 2014, 06:21 AM
hariom panday
plz hlp me in my project
iec.naga
Tue Sep 09 2014, 05:19 AM
spi
Mon Sep 08 2014, 12:14 PM
fameem
water changing in fish tank automatically using microcontoller with timer. send idea to me
dexter_a
Sat Sep 06 2014, 03:09 PM
hello guys
Sat Sep 06 2014, 02:10 PM
munaxa
plx guide me
Sat Sep 06 2014, 02:09 PM
munaxa
hi i want to buy plx guie me
ajay_bhargav
Sat Sep 06 2014, 07:10 AM
@Ben, Its hard to undrstand the context like this. If you can post in forum with some example code we might answer you better.

Downloads

Comments

engwas
Tue Sep 30 2014, 12:42 PM
zsachico
Tue Sep 30 2014, 04:18 AM
evergreencare
Sat Sep 27 2014, 07:39 AM
Agnoor
Thu Sep 25 2014, 06:39 AM
fouadzeyad
Tue Sep 23 2014, 09:04 AM
deepbhadani
Fri Sep 19 2014, 05:08 PM
desaiakshay92
Fri Sep 19 2014, 04:45 AM
Fiddu
Thu Sep 18 2014, 06:28 AM

Online

Guests: 61, Members: 0 ...

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

Members: 37522
Newest member: engwas
Forum Activity
kirangowle Avatar
Posted By kirangowle
Sat Sep 20 2014, 04:35 AM
Hello All,I want to connect normal speaker (as a s...
ajay_bhargav Avatar
Posted By ajay_bhargav
Wed Sep 17 2014, 04:59 AM
I think its important to list out the features of ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Wed Sep 17 2014, 04:45 AM
you need to put a wait condition in ISR till the s...
akshar Avatar
Posted By akshar
Mon Sep 15 2014, 08:41 AM
sir,i used microcontroller 89v51rd2 in circuit. No...
bobparihar Avatar
Posted By bobparihar
Mon Sep 15 2014, 06:24 AM
i am programming interrupt 0 using 8051my task is....
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Sep 13 2014, 04:23 PM
There may not be an exact equivalent .You will hav...
akshar Avatar
Posted By akshar
Sat Sep 13 2014, 07:18 AM
Sir, Good Morning,Thank you for making me a member...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Sep 11 2014, 04:52 AM
which compiler are you using? I suggest XC8 with M...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Sep 11 2014, 04:49 AM
I always prefer Olimex Dev boards when it comes to...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Sep 11 2014, 04:44 AM
master will always lower down the Chip select... s...