📄 temp_adc.asm
字号:
MOV A,R7 ;subtract R1 from R7 to see if R1 < R7
SUBB A,R1 ;A = R7 - R1, carry set if R7 < R1
JC Cant_sub
JNZ Can_sub ;jump if R7>R1
CLR C
MOV A,R6
SUBB A,R0 ;A = R6 - R0, carry set if R6 < R0
JC Cant_sub
Can_sub:CLR C
MOV A,R6
SUBB A,R0 ; A = R6 - R0
MOV R6,A
MOV A,R7
SUBB A,R1 ; A = R7 - R1 - Borrow
MOV R7,A
SETB C ; shift a 1 into the quotient
ljmp Quot
Cant_sub: CLR C
Quot: LCALL Shift_Q ; Test for competion
DJNZ R5,Div_loop ; Now we are all done, move the TMP values back into OP
MOV t00,TMP_0
MOV t11,TMP_1
MOV t2,TMP_2
MOV t3,TMP_3
RET
Shift_D:CLR C
MOV A,t00
RLC A
MOV t00,A
MOV A,t11
RLC A
MOV t11,A
MOV A,t2
RLC A
MOV t2,A
MOV A,t3
RLC A
MOV t3,A
RET
Shift_Q:MOV A,TMP_0
RLC A
MOV TMP_0,A
MOV A,TMP_1
RLC A
MOV TMP_1,A
MOV A,TMP_2
RLC A
MOV TMP_2,A
MOV A,TMP_3
RLC A
MOV TMP_3,A
RET
hex_to_dec: ;Routine convert 4 byte hex into 8 digit decimal ascii
mov out7,#00h ;Input in t3,t2,t1,t0 and output in out7,out6,out5,out4,out3,out2,out1,out0 variables
mov out6,#00h
mov out5,#00h
mov out4,#00h
mov out3,#00h
mov out2,#00h
mov out1,#00h
mov out0,#00h
mov hex1,#00h
mov hex0,#0ah
mov a,t2
cjne a,#00h,xbn56
mov a,t11
cjne a,#00h,xbn57
lcall division_16
mov out0,r6
lcall division_16
mov out1,r6
mov out2,t00
sjmp over56
xbn57: lcall division_16
mov out0,r6
lcall division_16
mov out1,r6
lcall division_16
mov out2,r6
lcall division_16
mov out3,r6
mov out4,t00
sjmp over56
xbn56: lcall division_16
mov out0,r6
lcall division_16
mov out1,r6
lcall division_16
mov out2,r6
lcall division_16
mov out3,r6
lcall division_16
mov out4,r6
lcall division_16
mov out5,r6
lcall division_16
mov out6,r6
mov out7,t00
over56: orl out7,#30h ;converting all decimal values to ASCII
orl out6,#30h
orl out5,#30h
orl out4,#30h
orl out3,#30h
orl out2,#30h
orl out1,#30h
orl out0,#30h
ret
dec_to_hex: ;Routine convert the 4 digit decimal into 2 byte hex
mov r0,#00h ;Input in t3 t2 t1 t0 and output in hex1 hex0
mov r1,#00h
mov r2,#00h
mov r3,#00h
mov r4,#00h
mov r5,#00h
mov r6,#00h
mov r7,#00h
mov hex1,#00h
mov hex0,#00h
mov r0,t3
cjne r0,#00h,load0
ljmp load1
load0: mov a,r0
mov b,#0ah
mul ab
mov r0,a
mov r7,a
mov m641,#64h
load1: mov r2,t2
cjne r2,#00h,load2
ljmp load3
load2: mov m640,#64h
load3: mov r4,t11
cjne r4,#00h,load5
ljmp load6
load5: mov a,r4
mov b,#0ah
mul ab
mov r4,a
mov r6,a
load6: mov r5,t00
cjne r5,#00h,starting
nop
starting:mov r5,t00
cjne r5,#00h,here5
ljmp now2
here5: inc hex0
djnz r5,here5
now2: mov a,r6
mov r4,a
cjne r4,#00h,here4
ljmp now3
here4: inc hex0
djnz r4,here4
now3: mov r2,t2
cjne r2,#00h,here3
ljmp now4
here3: mov r3,m640
here2: clr c
mov a,hex0
add a,#01h
mov hex0,a
mov a,hex1
addc a,#00h
mov hex1,a
cont: djnz r3,here2
djnz r2,here3
now4: mov a,r7
mov r0,a
cjne r0,#00h,here1
ljmp home
here1: mov r1,m641
here0: clr c
mov a,hex0
add a,#01h
mov hex0,a
mov a,hex1
addc a,#00h
mov hex1,a
cont1: djnz r1,here0
djnz r0,here1
home: ret
thfound: ;routine provide threshold value range from 20 to 49 degree celcius for user
mov r6,a
cjne r6,#01h,dec_th
inc threshold0
mov a,threshold0
cjne a,#3ah,ter_return
mov a,threshold1
cjne a,#34h,notninerth
mov threshold1,#32h
mov threshold0,#30h
sjmp ter_return
notninerth:
inc threshold1
mov threshold0,#30h
sjmp ter_return
dec_th: cjne r6,#02h,ter_return
dec threshold0
mov a,threshold0
cjne a,#2fh,ter_return
mov a,threshold1
cjne a,#32h,notzerorth
mov threshold1,#34h
mov threshold0,#39h
sjmp ter_return
notzerorth:
dec threshold1
mov threshold0,#39h
ter_return:
mov lcdcom,#0c5h
lcall command
mov disp_data,threshold1
lcall data_routine
mov disp_data,threshold0
lcall data_routine
lcall delay140m ;debouncing delay
lcall delay140m
lcall delay140m
ret
intfound: ;routine provide recording interval range from 01 to 99 secs for user
mov r6,a
cjne r6,#01h,dec_int
inc interval0
mov a,interval0
cjne a,#3ah,int_return
mov a,interval1
cjne a,#39h,notniner
mov interval0,#31h
mov interval1,#30h
sjmp int_return
notniner:inc interval1
mov interval0,#30h
sjmp int_return
dec_int:cjne r6,#02h,int_return
dec interval0
mov a,interval0
cjne a,#30h,int_return
mov a,interval1
cjne a,#30h,notzeror
mov interval0,#39h
mov interval1,#39h
sjmp int_return
notzeror:dec interval1
mov interval0,#39h
int_return: mov lcdcom,#0c5h
lcall command
mov disp_data,interval1
lcall data_routine
mov disp_data,interval0
lcall data_routine
lcall delay140m ;debouncing delay
lcall delay140m
lcall delay140m
ret
display_text: ;display a 16 byte in ASCII string on lcd
mov count,#0fh
nextchar:mov a,#00h
movc a,@a+dptr
mov disp_data,a
lcall data_routine
inc dptr
mov a,count
cjne a,#00h,next1
sjmp here11
next1: dec count
sjmp nextchar
here11: ret
lcd_initialize: ;initialize lcd
mov lcdcom,#38h ;5*7 matrix 16*2 char lcd
lcall command
lcall delay40u
mov lcdcom,#01h ;clear lcd
lcall command
lcall delay14m
mov lcdcom,#0Eh ;blink off, cursor ON, display ON
lcall command
lcall delay40u
mov lcdcom,#06h ;shift cursor right
lcall command
lcall delay40u
ret
clear_lcd:mov lcdcom,#01h ;clear LCD screen
lcall command
lcall delay14m
mov lcdcom,#80h
lcall command
ret
cursoroff: ;lcd cursor off
mov lcdcom,#0ch
lcall command
ret
cursoron: ;lcd cursor on
mov lcdcom,#0eh
lcall command
ret
command: ;routine to send the command to LCD
clr p3.2 ;rs=0
clr p3.3 ;rw=0
lcall delay10u ;delay of 10usec
setb p3.4 ;E=1;
lcall delay10u ;delay of 10usec
mov p1,lcdcom ;mov data
lcall delay10u ;delay of 10usec
clr p3.4 ;E=0
lcall delay10u
setb p3.3 ;rw=1
lcall delay40u
ret
data_routine: ;routine to send ASCII data to LCD
setb p3.2 ;rs=1
clr p3.3 ;rw=0
lcall delay10u
setb p3.4 ;E=1;
lcall delay10u
mov p1,disp_data
clr p3.4 ;E=0
lcall delay40u
ret
delay10u: ;delay of 10 usec
mov r4,#04h
here10u:djnz r4,here10u
ret
delay40u: ;delay of 40 usec
mov r3,#09h
here1_40u: mov r4,#01h
here2_40u: djnz r4,here2_40u
djnz r3,here1_40u
ret
delay14m: ;delay of 14 msec
mov r3,#0ffh
here1_14m: mov r4,#18h
here2_14m: djnz r4,here2_14m
djnz r3,here1_14m
ret
delay140m: ;delay of 140 msec
mov r3,#0ffh
here1_140m: mov r4,#0ffh
here2_140m: djnz r4,here2_140m
djnz r3,here1_140m
ret
delay1sec: mov r3,#08h ;delay of 1 sec
here1_1s: mov r4,#0ffh
here2_1s: mov r5,#0ffh
here3_1s: djnz r5,here3_1s
djnz r4,here2_1s
djnz r3,here1_1s
ret
org 0700h
db 'MAJOR PROJECT'
org 0710h
db 'DATA ACQUISITION'
org 0720h
db 'SYSTEM'
org 0730h
db 'Enter Parameters'
org 0740h
db 'Measure Interval'
org 0750h
db 'Threshold value '
org 0760h
db 'Parameters Saved'
org 0770h
db 'Temperature '
org 0780h
db 'Sample no. '
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -