📄 aad.asm
字号:
;============================寄存器定义=====================================
status equ 03h
porta equ 05h
portb equ 06h
portc equ 07h
trisa equ 85h
trisb equ 86h
trisc equ 87h
option_reg equ 80h
intcon equ 0bh
tmr0 equ 01h
pir1 equ 0ch
adresh equ 1eh
adcon0 equ 1fh
adcon1 equ 9fh
t1con equ 10h
tmr1l equ 0eh
tmr1h equ 0fh
;============================变量声明========================================
adr equ 20h
adr_deci equ 21h
adr_int equ 22h
temp1 equ 23h
temp2 equ 24h
bcd_count equ 25h
disp_count equ 26h
tmr1_count equ 27h
max equ 28h
min equ 29h
max_temp equ 30h
min_temp equ 31h
disp_dig equ 32h
disp_seg equ 33h
;============================常量声明========================================
tmr1lb equ 0dch
tmr1hb equ 0bh
;============================复位矢量和中断矢量==============================
org 000h
nop
goto main
org 004h
;============================TMR1中断服务程序================================
tmr1_int bcf pir1,0
bcf t1con,0
movlw tmr1lb
movwf tmr1l
movlw tmr1hb
movwf tmr1h
decfsz tmr1_count,1
retfie
goto again
;============================主程序==========================================
main call initial
again btfsc portb,0
goto next1
call delay10
btfsc portb,0
goto next1
call change_max
next1 btfsc portb,1
goto next2
call delay10
btfsc portb,1
goto next2
call change_min
next2 call ad_trans
;============================判断温度是否为100℃==============================
movf adr,0
sublw 0feh
btfsc status,0
call bcd_trans
bsf porta,3
movlw 01h
movwf disp_dig
movlw 00h
movwf disp_seg
call display
movlw 02h
movwf disp_dig
movlw 00h
movwf disp_seg
call display
movlw 03h
movwf disp_dig
movlw 01h
movwf disp_seg
call display
movlw 04h
movwf disp_dig
movlw 00h
movwf disp_seg
call display
;============================上下限报警及数据显示=============================
movf max,0
subwf adr,0
btfss status,0
goto next3
bsf porta,3
goto next5
next3 movf adr,0
subwf min,0
btfss status,0
goto next4
bsf porta,5
goto next5
next4 bcf porta,3
bcf porta,5
next5 movlw 01h
movwf disp_dig
movf adr,0
andlw 0fh
movwf disp_seg
call display
movlw 02h
movwf disp_dig
swapf adr,0
andlw 0fh
movwf disp_seg
call display
movlw 03h
movwf disp_dig
movlw 00h
movwf disp_seg
call display
movlw 04h
movwf disp_dig
movlw 00h
movwf disp_seg
call display
call delay30
call delay30
call delay30
goto again
;============================延时10ms子程序=====================================
delay10 bcf intcon,2
movlw 0b2h
movwf tmr0
l1 btfss intcon,2
goto l1
return
;============================延时30ms子程序=====================================
delay30 bcf intcon,2
movlw 16h
movwf tmr0
l2 btfss intcon,2
goto l2
return
;============================初始化子程序=======================================
initial
;============================输入输出口初始化===================================
bsf status,5
movlw 01h
movwf trisa
movlw 17h
movwf trisb
movlw 00h
movwf trisc
movlw 07h
movwf option_reg
;============================TMR1初始化=========================================
bsf pir1,0
bcf status,5
movlw 34h
movwf t1con
movlw 0c0h
movwf intcon
movlw tmr1lb
movwf tmr1l
movlw tmr1hb
movwf tmr1h
movlw 1eh
movwf tmr1_count
movlw 60h
movwf max
movlw 20h
movwf min
;============================7219初始化=========================================
movlw 0ch
movwf disp_dig
movlw 01h
movwf disp_seg
call display
movlw 0fh
movwf disp_dig
movlw 00h
movwf disp_seg
call display
movlw 0bh
movwf disp_dig
movlw 03h
movwf disp_seg
call display
movlw 09h
movwf disp_dig
movlw 0ffh
movwf disp_seg
call display
movlw 0ah
movwf disp_dig
movlw 0fh
movwf disp_seg
call display
return
;============================A/D转换子程序=========================================
ad_trans bsf status,5
movlw 0eh
movwf adcon1
bcf status,5
movlw 41h
movwf adcon0
bsf adcon0,2
loop_ad nop
btfsc adcon0,2
goto loop_ad
movf adresh,0
movwf adr
return
;============================标度变化转换子程序=====================================
bcd_trans
;============================小数进位部分处理=======================================
movf adr,0
movwf temp1
movwf temp2
rlf temp1,1
rlf temp1,1
rlf temp1,1
movf temp1,0
movwf temp2
rlf temp1,1
movlw 30h
andwf temp1,1
movlw 38h
andwf temp2,1
movf temp2,0
addwf temp1,1
movf adr,0
movwf temp2
movlw 3fh
andwf temp2,1
movf temp2,0
addwf temp1,0
movwf adr_deci
;============================整数部分处理===========================================
movf adr,0
movwf temp1
movwf temp2
rrf temp1,1
rrf temp1,1
movlw 3fh
andwf temp1,1
rrf temp2,1
rrf temp2,1
rrf temp2,1
movlw 1fh
andwf temp2,1
movf temp2,0
addwf temp1,1
movf adr,0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -