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

Downloads

Comments

nnannos
Fri Apr 18 2014, 01:23 PM
venkyrsv
Fri Apr 18 2014, 12:10 PM
Suilied
Fri Apr 18 2014, 10:44 AM
RaviKantSharma
Fri Apr 18 2014, 04:55 AM
sohil99
Fri Apr 18 2014, 03:09 AM
kanakiyajay
Fri Apr 18 2014, 02:00 AM
bradstormer
Thu Apr 17 2014, 05:32 PM
jasmeet_singh
Thu Apr 17 2014, 10:19 AM

Conversation

ExperimenterUK
Thu Apr 17 2014, 01:23 PM
@mba Great .. please do.
Thu Apr 17 2014, 12:27 AM
mba'
like the forum and wish to participate
ExperimenterUK
Wed Apr 16 2014, 04:45 PM
@viniciusheidrun..you should read my comment just before your post
viniciusheidrun
Wed Apr 16 2014, 01:43 PM
I'm doing a drive system with SIM900D modem and microcontroller AT89S52 via sms. I'm having trouble can not generate the. Hex to send to the microcontroller, whenever I compile the error, I'm using MCU 8051 IDE, what should I do so that my system receive sms and perform my task?
ExperimenterUK
Mon Apr 14 2014, 01:00 PM
@Haranadh,bipin chandra etc. Create threads for your questions.
Sun Apr 13 2014, 04:05 AM
Haranadh
we bought HC 06 Bluetooth modem instead of Module ,Can any one help me of using it as bluetooth module since i am doing this project?
Sun Apr 13 2014, 03:58 AM
Haranadh
Hi,Actually we bought Bluetooth modem instead of Bluetooth Module
ajay_bhargav
Sat Apr 12 2014, 02:55 PM
Please use forum if you want to ask a question.
Sat Apr 12 2014, 01:06 PM
Dpk
Hi Ahana,I can Help you on this
Sat Apr 12 2014, 03:51 AM
bipin chandra
can anybody help me. we are making a project to control the position of dc motor. so there we need to interface lcd screen and the 4X3 memberane keypad and a dc motor driver chip. can anybody please give me the complete circuit diagram connection of these components with the 8051.and alse help in the programming. my email id is bipin.chandra666@gmail.com
  Choose Skin