Accelerometer MMA7660 interface to 8051 and display values on LCD

Status
Not open for further replies.

jaideep1992

Newbie level 1
Joined
Jan 28, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,304
Hello everyone
I am Jaideep pursuing Btech final year.
Currently i am doing my project titled "Vehicle Tracking and Accident Alert System"
It works with an acceleration sensor MMA7660 and depending on values obtained from it, the tilt is measured and accident is detected
Currently am facing projects in interfacing MMA7660 to 8051 since some Garbage values are coming on LCD

Here is my code:

sda equ P3.6
scl equ P3.7
org 00h
acall init

sa:
mov a,#98h
acall startc
acall send
acall mack
jc sa

amr:
mov a,#07h
acall send
acall mack
jc amr


am:
mov a,#09h
acall send
acall mack
jc am

start:
mov a,#98h
acall startc
acall send
acall mack
jc start

rax:
mov a,#00h
acall send
acall mack
jc rax

rby:
mov a,#01h
acall send
acall mack
jc rby

rcz:
mov a,#02h
acall send
acall mack
jc rcz

sar:
mov a,#99h
acall rstart
acall send
acall mack
jc sar
acall recv
acall ack
mov r0,a
acall recv
acall ack
mov r1,a
acall recv
acall nak
mov r2,a
acall stop

mov a,#38h
acall cmdwrt
acall delay

mov a,#0eh
acall cmdwrt
acall delay

mov a,#01h
acall cmdwrt
acall delay

mov a,#06h
acall cmdwrt
acall delay

mov a,#80h
acall cmdwrt
acall delay
mov a,#'X'
acall datawrt
acall delay

mov a,#81h
acall cmdwrt
acall delay
mov a,#'='
acall datawrt
acall delay

mov a,#82h
acall cmdwrt
acall delay
mov a,r0
acall datawrt
acall delay

mov a,#86h
acall cmdwrt
acall delay
mov a,#'Y'
acall datawrt
acall delay

mov a,#87h
acall cmdwrt
acall delay
mov a,#'='
acall datawrt
acall delay

mov a,#88h
acall cmdwrt
acall delay
mov a,r1
acall datawrt
acall delay

mov a,#8bh
acall cmdwrt
acall delay
mov a,#'Z'
acall datawrt
acall delay

mov a,#8ch
acall cmdwrt
acall delay
mov a,#'='
acall datawrt
acall delay

mov a,#8dh
acall cmdwrt
acall delay
mov a,r2
acall datawrt
acall delay

jmp start

cmdwrt:
mov p1,a
clr p2.0
clr p2.1
setb p2.2
acall delay
clr p2.2
ret

datawrt:
mov p1,a
setb p2.0
clr p2.1
setb p2.2
acall delay
clr p2.2
ret

delay:
mov r3,#0c8h
bck1:mov r4,#64h
bck:djnz r4,bck
djnz r3,bck1
ret

init:
setb sda
setb scl
ret

startc:
setb scl
clr sda
clr scl
ret

rstart:
clr scl
setb sda
setb scl
clr sda
ret

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

ack:
clr sda
setb scl
clr scl
setb sda
ret

mack:
setb scl
mov c, sda
clr scl
ret

nak:
setb sda
setb scl
clr scl
setb scl
ret

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

stop:
clr scl
clr sda
setb scl
setb sda
ret


end


Please help
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…