1、仿真程序仿真:LED_0 EQU 30HLED_1 EQU 31HLED_2 EQU 32HADC EQU 35HTCNTA EQU 36HTCNTB EQU 37HH_TEMP EQU 38HL_TEMP EQU 39HFLAG BIT 00HH_ALM BIT P3.0L_ALM BIT P3.1SOUND BIT P3.7CLOCK BIT P2.4ST BIT P2.5EOC BIT P2.6OE BIT P2.7ORG 00HSJMP STARTORG 0BHLJMP INT_T0ORG 1BHLJMP INT_T1START:MOV LED_0,#00HMOV LED_1,#00H
2、MOV LED_2,#00HMOV DPTR,#TABLEMOV H_TEMP,#153MOV L_TEMP,#77MOV TMOD,#12HMOV TH0,#245MOV TL0,#0MOV TH1,#(65536-1000)/256MOV TL1,#(65536-1000)/256MOV IE,#8AHCLR CSETB TR0WAIT:SETB H_ALMSETB L_ALMCLR STSETB STCLR STJNB EOC,$SETB OEMOV ADC,P1CLR OEMOV A,ADCSUBB A,L_TEMPJC LALMMOV A,H_TEMPMOV R0,ADCSUBB A
3、,R0JC HALMCLR TR1LJMP PROC1LALM:CLR L_ALMSETB TR1CLR FLAGLJMP PROC1HALM:CLR H_ALMSETB TR1SETB FLAGLJMP PROC1PROC1:MOV A,ADCMOV B,#100DIV ABMOV LED_2,AMOV A,BMOV B,#10DIV ABMOV LED_1,AMOV LED_0,BLCALL DISPSJMP WAITINT_T0:CPL CLOCKRETIINT_T1:MOV TH1,#(65536-1000)/256MOV TL1,#(65536-1000)/256CPL SOUNDI
4、NC TCNTAMOV A,TCNTAJB FLAG,I1CJNE A,#30,RETUNESJMP I2I1:CJNE A,#20,RETUNEI2:MOV TCNTA,#0INC TCNTBMOV A,TCNTBCJNE A,#25,RETUNEMOV TCNTA,#0MOV TCNTB,#0LCALL DELAY2RETUNE:RETIDISP:MOV A,LED_0MOVC A,A+DPTRCLR P2.3MOV P0,ALCALL DELAYSETB P2.3MOV A,LED_1MOVC A,A+DPTRCLR P2.2MOV P0,ALCALL DELAYSETB P2.2MOV A,LED_2MOVC A,A+DPTRCLR P2.1MOV P0,ALCALL DELAYSETB P2.1RETDELAY:MOV R6,#10D1:MOV R7,#250DJNZ R7,$DJNZ R6,D1RETDELAY2:MOV R5,#20D2:MOV R6,#20D3:MOV R7,#250DJNZ R7,$DJNZ R6,D3DJNZ R5,D2RETTABLE:DB 3FH,06H,5BH,4FH,66HDB 6DH,7DH,07H,7FH,6FHEND