帮忙注述 汇编语言
LED_0 EQU 30HLED_1 EQU 31H
LED_2 EQU 32H
ADC EQU 35H
TCNTA EQU 36H
TCNTB EQU 37H
H_TEMP EQU 38H ;温度上限
L_TEMP EQU 39H ;温度下限
FLAG EQU 020H.0
H_ALM BIT P3.0
L_ALM BIT P3.1
SOUND BIT P3.7
CLOCK BIT P2.4
ST BIT P2.5
EOC BIT P2.6
OE BIT P2.7
ORG 00H
SJMP START
ORG 000BH
LJMP INT_T0
ORG 001BH
LJMP INT_T1
ORG 0030H
START: MOV LED_0,#00H
MOV LED_1,#00H
MOV LED_2,#00H
MOV DPTR,#TABLE
MOV H_TEMP,#35 ;上限35
MOV L_TEMP,#15 ;下限15
MOV TMOD,#12H
MOV TH0,#245
MOV TL0,#245
MOV TH1,#0D8H ;和你的一样的数值.我的编译器不支持表达式
MOV TL1,#0F0H
MOV IE,#8aH
CLR C
SETB TR0 ;为ADC0808提供时钟
WAIT: SETB H_ALM
SETB L_ALM
CLR ST
nop
SETB ST
nop
CLR ST ;启动转换
JNB EOC,$
SETB OE
mov p1,#0ffh
MOV ADC,P1 ;读取AD转换结果
CLR OE
MOV A,ADC
SUBB A,L_TEMP ;判断是否低于下限 (這個地方忽略了)
JC LALM
mov a,ADC
SUBB A,H_TEMP ;判断是否高于上限
JNC HALM
CLR TR1
LJMP PROC1
LALM: SETB H_ALM ;低温报警
CLR L_ALM
SETB TR1
CLR FLAG
LJMP PROC1
HALM: SETB L_ALM ;高温报警
CLR H_ALM
SETB TR1
SETB FLAG
LJMP PROC1
PROC1: MOV A,ADC ;数值转换
MOV B,#100
DIV AB
MOV LED_2,A
MOV A,B
MOV B,#10
DIV AB
MOV LED_1,A
MOV LED_0,B
LCALL DISP
AJMP WAIT
INT_T0: CPL CLOCK ;提供ADC0808时钟
RETI
INT_T1: MOV TH1,#0D8H
MOV TL1,#0F0H
CPL SOUND
INC TCNTA
MOV A,TCNTA
JB FLAG,I1 ;判断是高温警报还是低温警报
CJNE A,#30,RETUNE ;低温警报声
SJMP I2
I1: CJNE A,#20,RETUNE ;高温警报声
I2: MOV TCNTA,#0
INC TCNTB
MOV A,TCNTB
CJNE A,#25,RETUNE
MOV TCNTA,#0
MOV TCNTB,#0
LCALL DELAY2
RETUNE: RETI
DISP: MOV A,LED_0 ;数码显示子程序
MOVC A,@A+DPTR
CLR P2.3
MOV P0,A
LCALL DELAY
SETB P2.3
MOV A,LED_1
MOVC A,@A+DPTR
CLR P2.2
MOV P0,A
LCALL DELAY
SETB P2.2
MOV A,LED_2
MOVC A,@A+DPTR
CLR P2.1
MOV P0,A
LCALL DELAY
SETB P2.1
RET
DELAY: MOV R6,#10
D1: MOV R7,#250
DJNZ R7,$
DJNZ R6,D1
RET
DELAY2: MOV R5,#20
D2: MOV R6,#20
D3: MOV R7,#250
DJNZ R7,$
DJNZ R6,D3
DJNZ R5,D2
RET
TABLE: DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
END