Sie sind auf Seite 1von 6

0rg 0000h ; Beginning address of the microprocessor

Jmp start

Rs bit p3.3
En bit p3.4
Ed bit p3.5

Lcd_data equ p1

Start: Mov a,#38h ; init LCD lines to 5_by_7 matrix


Call wrt_instr ; call command subroutine
Call delay ; give LCD sometime
Mov a,#0ch ; display,cursor off
Call wrt_instr ; call command subroutine
Mov a,#01h ; clear LCD
Call wrt-instr ; call command subroutine
Call delay
Mov a,#06h ; shift cursor right
Call wrt_instr
Call delay
Mov a,#80h ; cursor at line 1,position 0
Call wrt-instr
Mov a,#�M� ; display letter m
Call wrt-data ; call display subroutine
Mov a,#�U� ; display letter u
Call wrt-data ; call display subroutine
Mov a,#�L�
Call wrt-data
mov a,#�T�
call wrt-data
mov a,# �I �
call wrt-data
mov a,# �_�
call wrt-data

mov a,# �W�


call write-data
mov a,# �I �
call wrt-data
mov a,# �R�
call wrt-data
mov a,# �E�
call write-data

mov a,# � �
call wrt-data

mov a,# �C�


call wrt-data
mov a,# �A�
call write-data
mov a,# �B �
call wrt-data
mov a,# �L�
call wrt-data
mov a,# �E�
call write-data
mov a,# � �
call wrt-data

mov a,# �T �
call wrt-data
mov a,# �E�
call wrt-data
mov a,# �S�
call write-data
mov a,# �T �
call wrt-data
mov a,# �E�
call wrt-data
mov a,# �R�
call write-data

jmp serial-com

wrt-instr: mov LCD-data,a


clr Rs
clr Rd
setb En
clr En
ret

wrt-data:mov lcd_data,a ; copy reg A to p1


setb Rs ; Rs = 1 for dat
clr Rd ; Rl = 0 for write
setb En ; En = 1 for high pulse
clr En ; En = 0 for H-to-L Pulse.
ret

Delay:mov R3,#50
Mov R2 ,#255

delaya:djnz r2,delaya ; stay here until r2 becomes 0


djnz r3,delaya
ret

; confirmation of SFR ( special function Register ) for


; serial communication

serial-com:mov TMOD,#20h ; timer1, mode 2


mov TH1,#-3 ; 9600 baud
mov SCON,#50h ; 8-bits,start and stop bits, enabled.
;jmp start 2
end_1

;B SENDING DATA FROM TRANSMITTER TO RECEIVER

org 0040h

Start2:
Cable equ p2
Count equ 22h

Push_button bit p3.0

Next:MOV count,#00h ; init count to zero

MOV cable , #0ffh ; make p2 an input port

setb push-button ; make p3.0 an input pin

jb push-button,$ ; Remain here until button is pushed

jnb push-button,$ ; wait until button is released.

Mov cable,#2fh ; send data �2fh� to receiver

2 f

setb TRI ; Start timer 1

MOV a ,#2fh ; copy sent data accumulator

MOV sbuf,a ; copy accumulator to sbuf register

Here:jnb T1,Here ; wait for last bit to transfer


Clr T1 ; get ready for next byte
Call delay sms
Inc count
Cjne count,#05h,xx
Jmp next
End_2

; Receiver

org 0080h

Rs bit p3.3
Fn bit p3.4
Rd bit p3.5

LCD-data equ p1

Begin :mov a,#38h ; init LCD lines, 5*7 matrix


Call wrt-instr ; call command subroutine
Call delay ; give LCD some time
Mov a,#0ch ; display,cursor off
Mov a,#01h ; clear LCD
Call wrt_intrs
Call delay
Mov a,#06h ; shift cursor right
Call wrt-instr
Call delay
Mov a, 80h ; cursor at line 1,position 0
Call wrt-instr
Mov a, # �m� ; display letter M
Call wrt-data ; call display subroutine
Mov a, # �u� ; display letter u

jmp serial_reciver
;xxxxxxxxxxxxxx
Delay:

;xxxxxxxxxxxxxx

serial_reciver:mov count, #00h ; init count to zero


Jnb R1,$ ; wait until last bit is received.
Mov a,sbuf ; copy received data to accumulator
Clr RI
MOV r7,a ; copy received data to register
MOV a,cable ; data from cable to accumulator

Cjne r7,a,Repeat ; compare the two data received


Inc count_good
Cjne count,#05h,serial_reciver
Jmp dis_good_Result

Repeat:inc count_bad
Cjne count,#05h,serial_reciver
Call display_bad_result

End__: jmp end__.

line1 equ 80h


line2 equ 0c0h
line3 equ 90h
line4 equ 0d0h

cable_is_good:mov dptr,#dm_5
mov r0,#30h
call mov_next
mov dptr, #dm_6
mov r0,#40h
call mov_next
mov dptr, #dm_7
mov r0, #50h
call mov_next
mov dptr, #dm_8
mov r0, #60h
call mov_next
ret
cable_is_bad:mov dptr,#dm_1
mov r0,#30h
call mov_next
mov dptr, #dm_2
mov r0,#40h
call mov_next
mov dptr, #dm_3
mov r0, #50h
call mov_next
mov dptr, #dm_4
mov r0, #60h
call mov_next
ret

dm_1:db'THE CABLE IS IN#'


dm_2:db' BAD CONDITION.#'
dm_3:db' CHANGE IT AND #'
dm_4:db' TEST AGAIN. #'

dm_5:db' THE CABLE IS #'


dm_6:db'OKAY.THANKS FOR#'
dm_7:db'USING MULTIWIRE#'
dm_8:db' CABLE TESTER #'

mov_next: clr a
movc a,@a+dptr
mov @r0, a
inc r0
inc dptr
cjne A,#'#',mov_next
ret

Write_data:mov A,#line1
call wr_instr
call delay5ms
mov r0, #30h
write_data1:call display_data
cjne r0,#3fh, write_data1
mov a,#line2
call wr_instr
call delay5ms
mov r0,#40h
write_data2:call display_data
cjne r0,#4fh, write_data2
mov a, #line3
call wr_instr
call delay5ms
mov r0,#50h
write_data6:call display_data
cjne r0,#5fh,write_data6
mov a, #line4
call wr_instr
call delay5ms
mov r0, #60h
write_data5:call display_data
cjne r0,#6fh,write_data5
ret

delay15ms:mov r7,#20;39
mov r6,#180;229
jmp delay1
delay5ms:mov r7,#13
mov r6,#34;244
jmp delay1
delay1ms:mov r7,#3
mov r6,#147
jmp delay1
delays: mov r7,#39
mov r6,#200;229
delay1: djnz r6,$
djnz r7,delay1
jnb strt_bit,start
ret

end

Das könnte Ihnen auch gefallen