📄 wenduceshiyi
字号:
portb equ 06h
portc equ 07h
porte equ 09h
status equ 03h
rp0 equ 05h
adcon1 equ 9fh
option_reg equ 81h
portd equ 08h
trisb equ 86h
trisc equ 87h
trisd equ 88h
trise equ 89h
value equ 23h
fsr equ 04h
pcl equ 02h
lcdcode equ 2ah
pclath equ 0ah
maxl equ 50h
maxh equ 51h
maxl_temp equ 52h
maxh_temp equ 53h
minl equ 54h
minh equ 55h
minl_temp equ 56h
minh_temp equ 57h
lbyte_date equ 20h ;从18b20获取的低字节信息
hbyte_date equ 21h ;从18b20获取的高字节信息
count equ 29h
count1 equ 28h
count2 equ 27h
temp equ 3ah
w_temp equ 3ch
H_byte equ 31h ;要转换的高字节二进制数
L_byte equ 32h ;要转换的低字节二进制数
R0 equ 33h ;R0,R1,R2是储存计算结果的寄存器,其中R2是低位
R1 equ 34h
R2 equ 35h
intcon equ 0bh
t0if equ 2
tmr0 equ 1h
option_reg equ 81h
option_temp equ 0a6h
count4 equ 2bh
t0ie equ 5
comp_h equ 58h
comp_l equ 59h
org 000h
nop
main
movlw b'00110011'
movwf maxh_temp
movlw b'00111000'
movwf maxl_temp
movlw b'00110001'
movwf minh_temp
movlw b'00110000'
movwf minl_temp
call inilcd
use
call play18b20
call keycheck
goto mainend
keycheck
call scankeys
comf value,0
btfsc status,2 ;判断是否有按键按下
goto use ;没有按键则调用"键盘无输入,显示温度"
movlw 02h
movwf 22h
call delay ;键盘防抖动,延时30ms*2=60ms再检测
call scankeys
comf value,0
btfsc status,2 ;判断是否有按键按下
goto use
;没有按键则调用"键盘无输入,显示温度"
checkA
movf value,0 ;按"A"显示温度上限值
xorlw b'11011101'
btfsc status,2
call comemax
checkB
movf value,w ;按"B"显示温度下限值
xorlw b'11011110'
btfsc status,2
call comemin
checkC
movf value,0 ;按"c"修改上限值
xorlw b'11100111'
btfsc status,2
call changemax
checkD
movf value,0 ;按"D"修改下限值
xorlw b'11101011'
btfsc status,2
call changemin
checkF
movf value,0 ;按"F"显示温度
xorlw b'11101110'
btfsc status,2
call play18b20
goto use ;循环检测
return
inilcd bcf porte,0
bsf status,rp0 ;设置文件寄存器的体1
clrf trisd
clrf trise
movlw 6h ;e端口特殊,给adcon1寄存器赋6h使e端口为普通的数字i/o口
movwf adcon1
movlw 07h ;设置选项寄存器地址,将分频比
movwf option_reg ;设定为1:256
bcf status,rp0 ;恢复体0
;初始化具体过程
movlw 30h ;30h连送三次
call inlcd
movlw 30h
call inlcd
movlw 30h
call inlcd
movlw 38h ;功能设置:设定LCD格式为2行显示,5×7dot字形
call inlcd
movlw 08h ;关显示
call inlcd
movlw 01h ;清屏
call inlcd
movlw 06h ;设定输入方式为:增量方式显示,不移位
call inlcd
movlw 0fh
call inlcd
return
comemax
call inilcd
call clearlcd
call delay1ms
bsf status,5
clrf trisd
clrf trise
bcf status,5
bsf porte,0
movlw b'01010100' ;显示"T"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101000' ;显示"h"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100001' ;显示"a"
call inlcd
call delaylcd
bsf porte,0
movlw b'01111000' ;显示"x"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01110100' ;显示"t"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01110000' ;显示"p"
call inlcd
call delaylcd
bsf porte,0
movlw b'00111010' ;显示":"
call inlcd
call delaylcd
movlw b'11000000' ;换行显示
bcf porte,0
call inlcd
call afterdatalcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movf maxh_temp,0
call inlcd
bsf porte,0
movf maxl_temp,0
call inlcd
bsf porte,0 ;显示"o"
movlw b'11011111'
call inlcd
call delaylcd
bsf porte,0 ;显示"C"
movlw b'01000011'
call inlcd
call delaylcd
movlw 1eh
movwf 22h
call delay
call keycheck1
return
keycheck1
call scankeys
comf value,0
btfsc status,2 ;判断是否有按键
goto keycheck1 ;如果没有按键则返回keycheck2
movlw 02h
movwf 22h
call delay ;键盘防抖动,延时30ms*2=60ms
call scankeys
comf value,0 ;判断是否有按键
btfsc status,2
goto keycheck1 ;如果没有按键则返回keycheck2
movf value,w
xorlw b'11101110' ;按"f"储存
btfsc status,2
call play18b20 ;显示时间其实就是调用"键盘无输入,显示时间子程序"
call delay250ms
return
comemin
call inilcd
call clearlcd
call delay1ms
bsf status,5
clrf trisd
clrf trise
bcf status,5
bsf porte,0
movlw b'01010100' ;显示"T"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101000' ;显示"h"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101001' ;显示"i"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101110' ;显示"n"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01110100' ;显示"t"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01110000' ;显示"p"
call inlcd
call delaylcd
bsf porte,0
movlw b'00111010' ;显示":"
call inlcd
call delaylcd
movlw b'11000000' ;换行显示
bcf porte,0
call inlcd
call afterdatalcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movf minh_temp,0
call inlcd
bsf porte,0
movf minl_temp,0
call inlcd
bsf porte,0 ;显示"o"
movlw b'11011111'
call inlcd
call delaylcd
bsf porte,0 ;显示"C"
movlw b'01000011'
call inlcd
call delaylcd
movlw 1eh
movwf 22h
call delay
call keycheck1
return
changemax
call inilcd
call clearlcd
bsf porte,0
movlw b'01010011' ;显示"S"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'01110100' ;显示"t"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100001' ;显示"a"
call inlcd
call delaylcd
bsf porte,0
movlw b'01111000' ;显示"x"
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'01110100' ;显示"t"
call inlcd
call delaylcd
bsf porte,0
movlw b'01100101' ;显示"e"
call inlcd
call delaylcd
bsf porte,0
movlw b'01101101' ;显示"m"
call inlcd
call delaylcd
bsf porte,0
movlw b'01110000' ;显示"p"
call inlcd
call delaylcd
bsf porte,0
movlw b'00111010' ;显示":"
call inlcd
call delaylcd
movlw b'11000000' ;换行显示
bcf porte,0
call inlcd
call afterdatalcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
bsf porte,0
movlw b'00100000' ;显示" "
call inlcd
call delaylcd
call keyinidis
movf lcdcode,0
movwf maxh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -