Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

89s52+serial eeprom (24c512)

Status
Not open for further replies.

shankardy

Newbie level 2
Joined
Apr 18, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,319
89s52 eeprom

hi,
i am doing project of datalogger and am using 24c512 for memory purpose.
i have tried to interface 89s52 and 24c512 with i2c protocol but not successful yet. please see my code and if possible help me please.as it is for only for testing purpose i am sending only letter 'S' to be written and read afterwards. please try to help as soon as possible my exams starting in next week.

here is the mine tried code


org 00h

sda equ P1.1
scl equ P1.0

write equ 10100000b ;control byte for writing
read equ 10100001b ;control byte for reading

;initializing of i2c
clr sda
clr scl
nop
setb sda
setb scl
ret

startc: ;starting i2c communication
setb scl
clr sda
clr scl
nop
nop
lcall writenow
stop: ;stoping i2c communication
clr scl
clr sda
setb scl
setb sda
ret


writenow:clr sda
clr scl
mov a,#write
lcall send
setb sda
setb scl
jb sda,writenow
clr scl
mov a,#00000000b
lcall send
setb sda
setb scl
jb sda,writenow
clr scl
mov a,#00000000b
lcall send
setb sda
setb scl
jb sda,writenow
clr scl

mov a,#53h ;hex equivalent for 'S'
lcall send
setb sda
setb scl
jb sda,writenow

clr scl

setb sda
clr scl
setb scl
setb sda
ret

readnow:clr sda
clr scl
mov a,#write
lcall send
setb sda
setb scl
jb sda,readnow
clr scl
mov a,#00000000b
lcall send
setb sda
setb scl
jb sda,readnow
clr scl
mov a,#00000000b
lcall send
setb sda
setb scl
jb sda,readnow
clr scl
mov a,#read
lcall send
setb sda
setb scl
jb sda,readnow
clr scl
lcall recv
setb sda
setb scl
clr scl

setb sda
acall display
lcall stop

display: mov r0,#38h ;LCD initialization subroutine
acall command
acall delay
mov r0,#0ch
acall command
acall delay
mov r0,#01h
acall command
acall delay
mov r0,#06h
acall command
acall delay
mov r0,#0c5h
acall command
acall delay
mov r0,a
acall data
acall delay
command:
mov p2,r0
acall delay
clr p1.2 ;r/w pin of lcd is grounded
setb p1.4
acall delay
clr p1.4
ret

data:
mov p2,r0
acall delay
setb p1.2
setb p1.4
acall delay
clr p1.4
ret


delay: mov r6,#60
here4: mov r7,#50
here1: djnz r7,here1
djnz r6,here4


send:
mov r7,#08
back:
clr scl
rlc a
mov sda,c
setb scl
lcall delay
djnz r7,back
clr scl
setb sda
ret

recv:
mov r7,#08
back2:
clr scl
setb scl
mov c,sda
rlc a
lcall delay
djnz r7,back2
clr scl
setb sda
ret
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top