zoukankan      html  css  js  c++  java
  • 可定时温湿控制器

    ;#################################################

    ;程序名称:可定时温湿控制器

    ;功能:实时检测温湿度并显示,并且控制相应的设备进行除湿、加湿、降温、加热。

    ;主控芯片:89c51,12MHZ

    ;程序编写者:buyixin(不亦心)

    ;编写时间:2009年

    ;注明:这里只给出草稿程序(仅用于仿真,商用需求请留言联系),并未优化,也去除了注释

    ;不亦心的博客:http://hi.baidu.com/不亦心/

    ;##################################################################


    DQ EQU P1.0 ;单总线
    SHEZHI EQU P1.1 ;设置温度,湿度,时间
    JIA EQU P1.2   ;加键
    JIAN EQU P1.3 ;减键
    MSURE EQU P1.4 ;确认键
    SHEZHI1 EQU P1.5 ;调整时间键
    IN555 EQU P1.6 ;触发555信号
    OUT555 EQU P1.7 ;单稳态电路输入端
    JIANGWEN EQU P3.0
    JIARE EQU P3.1
    CHUSHI EQU P3.6
    JIASHI EQU P3.7
    ANJIAN1 BIT 20H.0 ;设置键标志位
    ANJIAN2 BIT 20H.1 ;加键标志位
    ANJIAN3 BIT 20H.2 ;减键标志位
    ANJIAN4 BIT 20H.3 ;确认键标志位
    ANJIAN5 BIT 20H.4 ;切换键标志位
    ANJIAN6 BIT 20H.5 ;调整时间标志位
    SHAN BIT 20H.6    ;设置秒闪标志
    BT0 BIT 20H.7     ;调时秒闪标志
    HOUR DATA 6DH     ;小时单元
    MINUTE DATA 6EH   ;分单元
    SECOND DATA 6FH   ;秒单元
    TIMEH DATA 5EH    ;定时小时单元
    TIMEL DATA 5FH    ;定时分单元
    TIME DATA 7BH     ;计时器1中断计数位
    TEMPH DATA 7CH    ; 定温度高限单元
    TEMPL DATA 7DH    ; 定温度低限单元
    SHIH DATA 7EH     ; 定湿度高限单元
    SHIL DATA 7FH     ; 定湿度低限单元
    ORG 0000H
    SJMP START
    ORG 0003H
    LJMP INTR0
    ORG 000BH
    LJMP INTIME
    ORG 0013H
    LJMP INTR1
    ORG 30H
    START: SETB JIANGWEN ;置1设备控制口
    SETB JIARE
    SETB CHUSHI
    SETB JIASHI
    MOV TMOD,#11H ;定时器初始化
    MOV TL1,#0B4H
    MOV TH1,#3CH
    MOV TL0,#0B4H
    MOV TH0,#3CH
    SETB PT0   ;定时器0高级中断
    SETB IT1   ;外部中断采用边沿触发
    SETB IT0
    SETB EA    ;开中断
    SETB EX0
    SETB EX1
    SETB ET0

    MOV SP,#30H ;设置堆栈指针
    MOV HOUR,#00H ;清零各数据缓存区
    MOV MINUTE,#00H
    MOV SECOND,#00H
    MOV 70H,#00H
    MOV 71H,#00H
    MOV 72H,#00H
    MOV 73H,#00H
    MOV 74H,#00H
    MOV 75H,#00H
    MOV 76H,#00H
    MOV 77H,#00H
    MOV TEMPH,#1CH ;初始化温,湿,时间的设定值
    MOV TEMPL,#00H
    MOV SHIH,#3CH
    MOV SHIL,#1EH
    MOV TIMEH,#11H
    MOV TIMEL,#1EH
    LCALL DS18B20 ;调用温度传感器初始化子程序
    MAIN: LCALL DISPLAY ;调用温度显示子程序
    LCALL REDTEMP ;调用读取温度子程序
    LCALL DATAC ;调用数据处理子程序
    LCALL BCD ;转化为BCD侣?
    MOV R1,#0FH ;把温度显示嵌入延时程序,防止显示有闪烁感
    DEL02: MOV R7,#7DH
    DEL12: MOV R6,#0C6H
    LCALL DISPLAY
    DEL22: DJNZ R6,DEL22
    DJNZ R7,DEL12
    DJNZ R1,DEL02
    CLR C   ;把温度值与设定值比较
    MOV A,61H
    CJNE A,TEMPH,BIJIAO2
    CLR JIANGWEN
    BIJIAO2: SETB JIARE
    JC JIAR
    CLR JIANGWEN
    SJMP OUT2
    JIAR: SETB JIANGWEN
    CJNE A,TEMPL,BIJIAO3
    CLR JIARE
    SJMP OUT2
    BIJIAO3: JNC OUT2
    CLR JIARE
    OUT2:LCALL SHIDU ;调用湿度检测子程序
    MOV R1,#20H    ;把湿度显示嵌入循环体,显示
    DEL01: MOV R7,#7DH
    DEL11: MOV R6,#0C6H
    LCALL DISPLAY2
    DEL21: DJNZ R6,DEL21
    DJNZ R7,DEL11
    DJNZ R1,DEL01
    SJMP MAIN

    ;温度检测相关子程序
    ;初始化温度传感器子程序
    DS18B20: LCALL RESET ;调用DS18B20复位子程序
    MOV A,#0CCH   ;跳过ROM  
    LCALL WRITE    ;调用ds18b20子程序
    MOV A,#4EH    ;写Ds18b20存储器
    LCALL WRITE    
    MOV A,#00H    ;写温度上限
    LCALL WRITE
    MOV A,#00H
    LCALL WRITE
    MOV A,#7FH     ;设置精度12位,精确的0.0625度
    LCALL WRITE
    RET
    ;读取温度子程序
    REDTEMP: LCALL RESET
    MOV A,#0CCH
    LCALL WRITE
    MOV A,#44H
    LCALL WRITE
    LCALL DELAY750 ;延迟750毫秒,12位温度转化需750毫秒
    LCALL RESET
    MOV A,#0CCH
    LCALL WRITE
    MOV A,#0BEH ;读命令
    LCALL WRITE
    LCALL READ
    MOV 66H,65H ;温度低字节
    LCALL READ
    MOV 67H,65H ;温度高字节
    RET
    ;温度显示子程序

    DISPLAY: MOV R0,#71H
    MOV R3,#0FDH
    MOV A,R3
    DIR0: MOV P2,A
    MOV A,@R0
    CJNE R0,#73H,MM
    MOV DPTR,#DEG2
    MOVC A,@A+DPTR
    SJMP TT
    MM: MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    TT: MOV P0,A
    MOV R5,#02H
    DELAY: MOV R4,#0FFH
    DJNZ R4,$
    DJNZ R5,DELAY
    INC R0
    MOV A,R3
    JNB ACC.7,DIR1
    RL A
    MOV R3,A
    SJMP DIR0
    DIR1: RET
    DEG1: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,40H,00H,76H,38H,39H,77H ;徊幌允拘∈ 阕中吐?
    DEG2: DB 0BFH,86H,0DBH,0CFH,0E6H,0EDH,0FDH,87H,0FFH,0EFH,40H,00H;幌允拘∈ ?
    ;数据显示子程序
    ;温度的存放方式:小数部分从左到右依次是2的负一次方到负二次方
    ;符号位1111为负,0000为正。负数 要取反加1
    ;负号用#0AH,整数用#0BH对应的字型码
    ;皇 忠 艘?.0625转化,但汇编没有浮点数所以采取以下转化方式:整数部分把两个半
    ;蛔纸诤显谝豢榫托辛耍 ∈ 糠忠 捎眉臃ㄖ噶睿 ?101就这样:0.5+0.25+0+0.0625
    ;整数低字节 整数低字节 整数低字节 整数低字节 小数 小数 小数 小数
    ;符号 符号 符号 符号 符号 整数高字节 整数高字节 整数高字节

    DATAC: MOV A,66H
    ANL A,#0fh
    MOV 60H,A ;徽馐侨⌒∈ 糠址旁?0H
    MOV A,66H  
    SWAP A
    ANL A,#0FH
    MOV R4,A   
    MOV A,67H
    SWAP A
    ANL A,#0FH
    MOV 62H,A ;环 盼淮嬗?2?
    MOV A,67H
    SWAP A
    ANL A,#0F0H
    ORL A,R4
    MOV 61H,A
    MOV A,62H
    CJNE A,#0FH,EE;患觳馐欠裎 盼?
    MOV 70H,#0AH ;皇歉海 罚埃人停#癆H表负,其他取反加1
    MOV A,60H
    CPL A
    ADD A,#01H
    MOV 60H,A
    MOV A,61H
    CPL A  
    ADDC A,#00H
    MOV 61H,A
    SJMP FF
    EE: MOV 70H,#0BH ;徽 蝗》矗 ?0bh表正
    FF: MOV 77H,#00H
    MOV 76H,#00H
    MOV 75H,#00H
    MOV 74H,#00H
    CLR C
    MOV A,60H
    JB ACC.0,Z1 ;小数部分乘以0.0625转化成显示温度值,用加法实现显示小数
    AA: JB ACC.1,Z2
    BB: JB ACC.2,Z3
    CC: JB ACC.3,Z4
    SJMP DD
    Z1: MOV 77H,#05H
    MOV 76H,#02H
    MOV 75H,#06H
    MOV 74H,#00H
    SJMP AA
    Z2: MOV A,#05H
    ADD A,76H
    MOV 76H,A
    MOV A,#02H
    ADD A,75H
    MOV 75H,A
    MOV A,#01H
    ADD A,74H
    MOV 74H,A
    MOV A,60H
    SJMP BB
    Z3: MOV A,#05H
    ADD A,75H
    MOV 75H,A
    MOV A,#02H
    ADD A,74H
    MOV 74H,A
    MOV A,60H
    SJMP CC
    Z4: MOV A,#05H
    ADD A,74H
    MOV 74H,A
    DD: MOV A,75H
    MOV B,#0AH
    DIV AB
    MOV 75H,B
    ADD A,74H
    MOV 74H,A
    RET
    ;蛔 怀桑拢茫穆耄 饕 乐挂?开头的数字这样不符合习惯的表示方法
    ;桓菏 允靖悍 牛 苯尤梅 攀 牍芪幻鸩涣?
    BCD: MOV A,61H   
    MOV B,#64H
    DIV AB   
    MOV 71H,A ;话傥凰停罚保?
    MOV A,B
    MOV B,#0AH
    DIV AB
    MOV 72H,A ;十位
    MOV 73H,B ;桓鑫?
    MOV A,71H
    CJNE A,#00H,GG ;环乐钩鱿郑?-001.0125"这样显示,纠正为"-0.0125"
    MOV A,72H
    CJNE A,#00H,HH
    MOV 72H,70H
    MOV 71H,#0BH
    SJMP GG
    HH: MOV 71H,70H
    GG: RET
    ;桓次蛔映绦颍 ㄐ判 樾吹模ㄊ樯系模?
    RESET: NOP
    L0: CLR DQ
    MOV R6,#0A0H
    L1: NOP
    DJNZ R6,L1
    SETB DQ
    MOV R6,#14H
    L4: DJNZ R6,L4
    CLR C
    ORL C,DQ
    JC L3
    MOV R5,#1EH
    L5: ORL C,DQ
    JC L3
    DJNZ R5,L5
    SJMP L0
    L3: MOV R6,#78H
    L2: DJNZ R6,L2
    RET
    ;欢磷映绦颍 ㄐ判 椋ㄊ樯系模?
    READ: MOV R6,#08H
    RE1: CLR DQ
    MOV R4,#04H
    NOP
    SETB DQ
    RE2: DJNZ R4,RE2
    MOV C,DQ   
    RRC A
    MOV R5,#16H
    NOP
    RE3: DJNZ R5,RE3
    DJNZ R6,RE1   
    MOV 65H,A     
    SETB DQ
    RET
    ;恍醋映绦颍 ㄐ判 椋ㄊ樯系模?
    WRITE: MOV R5,#08H
    W1: SETB DQ
    MOV R4,#06H
    RRC A          
    CLR DQ
    W2: DJNZ R4,W2
    MOV DQ,C      
    MOV R4,#16H
    NOP
    W3: DJNZ R4,W3
    DJNZ R5,W1
    SETB DQ
    RET
    ;谎邮弊映绦?
    DELAY750:MOV R1,#0FH
    DEL0: MOV R7,#7DH
    DEL1: MOV R6,#0C6H
    LCALL DISPLAY
    DEL2: DJNZ R6,DEL2
    DJNZ R7,DEL1
    DJNZ R1,DEL0
    RET

    INTR0: PUSH ACC
    MOV 7AH,R2
    PUSH 7AH
    CLR EX0
    SETB TR1
    LOOP: JNB TF1,LOOP1
    INC TIME
    CLR TF1
    MOV TL1,#0B4H
    MOV TH1,#3CH
    MOV A,TIME
    CJNE A,#20H,LOOP1
    MOV TIME,#00H
    CPL SHAN
    LOOP1: JB SHEZHI,TAIQI
    JB ANJIAN1,TAIQI
    SETB ANJIAN1
    INC R2
    CJNE R2,#07H,TAIQI
    MOV R2,#01H
    TAIQI: JNB SHEZHI,PAN1
    CLR ANJIAN1
    PAN1: JB JIA,TAIQI2
    JB ANJIAN2,TAIQI2
    SETB ANJIAN2
    CJNE R2,#00H,JIATEMPL
    LJMP TAIQI2
    JIATEMPL:CJNE R2,#01H,JIATEMPH
    INC TEMPL
    LJMP TAIQI2
    JIATEMPH: CJNE R2,#02H,JIASHIL
    INC TEMPH
    LJMP TAIQI2
    JIASHIL: CJNE R2,#03H,JIASHIH
    INC SHIL
    LJMP TAIQI2
    JIASHIH: CJNE R2,#04H,JIADHOUR
    INC SHIH
    JIADHOUR: CJNE R2,#05H,JIADMINUTE
    INC TIMEL
    LJMP TAIQI2
    JIADMINUTE: CJNE R2,#06H,TAIQI2
    INC TIMEH
    TAIQI2: JNB JIA,PAN2
    CLR ANJIAN2
    PAN2: JB JIAN,TAIQI3
    JB ANJIAN3,TAIQI3
    SETB ANJIAN3
    CJNE R2,#00H,JIANTEMPL
    LJMP TAIQI3
    JIANTEMPL: CJNE R2,#01H,JIANTEMPH
    DEC TEMPL
    LJMP TAIQI3
    JIANTEMPH: CJNE R2,#02H,JIANSHIL
    DEC TEMPH
    LJMP TAIQI3
    JIANSHIL: CJNE R2,#03H,JIANSHIH
    DEC SHIL
    LJMP TAIQI3
    JIANSHIH: CJNE R2,#04H,JIANDHOUR
    DEC SHIH
    JIANDHOUR: CJNE R2,#05,JIANDMINUTE
    DEC TIMEH
    LJMP TAIQI3
    JIANDMINUTE: CJNE R2,#06,TAIQI3
    DEC TIMEL
    TAIQI3: JNB JIAN,PAN3
    CLR ANJIAN3
    PAN3: CJNE R2,#01H,PP
    LCALL DISTEMP
    SJMP QQ
    PP: CJNE R2,#02H,YY
    LCALL DISTEMP
    SJMP QQ
    YY: CJNE R2,#03H,VV
    LCALL DISSHI
    SJMP QQ
    VV: CJNE R2,#04H,LL
    LCALL DISSHI
    SJMP QQ
    LL: CJNE R2,#05H,LJ
    LCALL DISTIME
    SJMP QQ
    LJ: CJNE R2,#06H,QQ
    LCALL DISTIME
    QQ: JB MSURE,TAIQI4
    JB ANJIAN4,TAIQI4
    SETB ANJIAN4
    SJMP OUT
    TAIQI4: JNB MSURE,OUT
    CLR ANJIAN4
    LJMP LOOP
    OUT: SETB EX0
    CLR TR1
    POP 7AH
    MOV R2,7AH
    POP ACC
    RETI

    DISTEMP: MOV A,TEMPH
    MOV B,#0AH
    DIV AB
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CJNE R2,#02H,ZC
    JB SHAN,SS
    ZC:CLR P2.0
    MOV P0,A
    SS: LCALL DELAY1
    SETB P2.0
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#02H,ZC1
    JB SHAN,SS1
    ZC1: CLR P2.1
    MOV P0,A
    SS1: LCALL DELAY1
    SETB P2.1
    MOV A,#0CH
    CLR P2.2
    MOVC A,@A+DPTR
    MOV P0,A
    LCALL DELAY1
    SETB P2.2
    MOV A,TEMPL
    MOV B,#0AH
    DIV AB
    MOVC A,@A+DPTR
    CJNE R2,#01H,ZC2
    JB SHAN,SS2
    ZC2: CLR P2.4
    MOV P0,A
    SS2: LCALL DELAY1
    SETB P2.4
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#01H,ZC3
    JB SHAN,SS3
    ZC3: CLR P2.5
    MOV P0,A
    SS3: LCALL DELAY1
    SETB P2.5
    MOV A,#0DH
    MOVC A,@A+DPTR
    CLR P2.6
    MOV P0,A
    LCALL DELAY1
    SETB P2.6
    MOV A,#0EH
    MOVC A,@A+DPTR
    CLR P2.7
    MOV P0,A
    LCALL DELAY1
    SETB P2.7
    RET

    DISSHI: MOV A,SHIH
    MOV B,#0AH
    DIV AB
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CJNE R2,#04H,ZC4
    JB SHAN,SS4
    ZC4: CLR P2.0
    MOV P0,A
    SS4: LCALL DELAY1
    SETB P2.0
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#04H,ZC5
    JB SHAN,SS5
    ZC5: CLR P2.1
    MOV P0,A
    SS5: LCALL DELAY1
    SETB P2.1
    MOV A,#0CH
    MOVC A,@A+DPTR
    CLR P2.2
    MOV P0,A
    LCALL DELAY1
    SETB P2.2
    MOV A,SHIL
    MOV B,#0AH
    DIV AB
    MOVC A,@A+DPTR
    CJNE R2,#03H,ZC6
    JB SHAN,SS6
    ZC6: CLR P2.4
    MOV P0,A
    SS6: LCALL DELAY1
    SETB P2.4
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#03H,ZC7
    JB SHAN,SS7
    ZC7: CLR P2.5
    MOV P0,A
    SS7: LCALL DELAY1
    SETB P2.5
    MOV A,#0DH
    MOVC A,@A+DPTR
    CLR P2.6
    MOV P0,A
    LCALL DELAY1
    SETB P2.6
    MOV A,#0FH
    MOVC A,@A+DPTR
    CLR P2.7
    MOV P0,A
    LCALL DELAY1
    SETB P2.7
    RET


    DISTIME: MOV A,TIMEH
    MOV B,#0AH
    DIV AB
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CJNE R2,#06H,ZC4T
    JB SHAN,SS4T
    ZC4T: CLR P2.0
    MOV P0,A
    SS4T: LCALL DELAY1
    SETB P2.0
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#06H,ZC5T
    JB SHAN,SS5T
    ZC5T: CLR P2.1
    MOV P0,A
    SS5T: LCALL DELAY1
    SETB P2.1
    MOV A,#0CH
    MOVC A,@A+DPTR
    CLR P2.2
    MOV P0,A
    LCALL DELAY1
    SETB P2.2
    MOV A,TIMEL
    MOV B,#0AH
    DIV AB
    MOVC A,@A+DPTR
    CJNE R2,#05H,ZC6T
    JB SHAN,SS6T
    ZC6T: CLR P2.4
    MOV P0,A
    SS6T: LCALL DELAY1
    SETB P2.4
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#05H,ZC7T
    JB SHAN,SS7T
    ZC7T: CLR P2.5
    MOV P0,A
    SS7T: LCALL DELAY1
    SETB P2.5
    MOV A,#0DH
    MOVC A,@A+DPTR
    CLR P2.6
    MOV P0,A
    LCALL DELAY1
    SETB P2.6
    MOV A,#08H
    MOVC A,@A+DPTR
    CLR P2.7
    MOV P0,A
    LCALL DELAY1
    SETB P2.7
    RET


    SHIDU: MOV TH0,#00H
    MOV TL0,#00H
    CLR IN555
    SETB TR0
    SETB IN555
    JB OUT555,$
    MOV A,TL0
    CLR TR0
    CLR C
    SUBB A,#18H
    SUBB A,#1FH
    MOV B,#02H
    DIV AB
    MOV 50H,A
    MOV B,#0AH
    DIV AB
    MOV 6AH,A
    MOV 6BH,B
    RET

    DISPLAY2: MOV A,6AH
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CLR P2.4
    MOV P0,A
    LCALL DELAY1
    SETB P2.4
    MOV A,6BH
    MOVC A,@A+DPTR
    CLR P2.5
    MOV P0,A
    LCALL DELAY1
    SETB P2.5
    MOV A,#0FH
    MOVC A,@A+DPTR
    CLR P2.6
    MOV P0,A
    LCALL DELAY1
    SETB P2.6
    MOV A,#0CH
    MOVC A,@A+DPTR
    CLR P2.7
    MOV P0,A
    LCALL DELAY1
    SETB P2.7
    CLR C
    MOV A,50H
    CJNE A,SHIH,BIJIAO
    CLR CHUSHI
    BIJIAO: SETB JIASHI
    JC JIAS
    CLR CHUSHI
    SJMP OUT1
    JIAS: SETB CHUSHI
    CJNE A,SHIL,BIJIAO1
    CLR JIASHI
    SJMP OUT1
    BIJIAO1: JNC OUT1
    CLR JIASHI
    OUT1: RET

    INTR1: SETB TR0
    MOV 55H,R3
    PUSH 55H
    PUSH PSW
    MOV 68H,R0
    PUSH 68H
    MOV R0,#00H
    MOV 69H,R2
    PUSH 69H
    PUSH ACC
    LOP: LCALL JIANPAN
    LCALL JISUAN
    LCALL DISPLAY1
    MOV A,HOUR
    CJNE A,TIMEH,OUTL
    MOV A,MINUTE
    CJNE A,TIMEL,OUTL
    SJMP OVER
    OUTL: LJMP LOP
    OVER: POP ACC
    POP 69H
    MOV R2,69H
    POP 68H
    MOV R0,68H
    POP PSW
    POP 55H
    MOV R3,55H
    MOV HOUR,#00H
    MOV MINUTE,#00H
    MOV SECOND,#00H
    RETI

    INTIME: MOV TL0,#0B4H
    MOV TH0,#3CH
    PUSH ACC
    LCALL JIANPAN
    INC R0
    POP ACC
    RETI

    JISUAN: CJNE R0,#20H,TIAOCHU
    MOV R0,#00H
    CPL BT0
    INC SECOND
    MOV A,SECOND
    CJNE A,#3CH,TIAOCHU
    MOV SECOND,#00H
    INC MINUTE
    MOV A,MINUTE
    CJNE A,#3CH,TIAOCHU
    MOV MINUTE,#00H
    INC HOUR
    MOV A,HOUR
    CJNE A,#18H,TIAOCHU
    MOV MINUTE,#00H
    TIAOCHU: RET

    DISPLAY1: MOV P2,#0FFH
    MOV A,HOUR
    CJNE A,#09H,XV
    SJMP VX
    XV: JC VX
    MOV B,#0AH
    DIV AB
    SJMP ZV
    VX: MOV A,#0BH
    MOV B,HOUR
    SJMP ZV
    ZV: MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    SHANSHUO: CJNE R2,#01H,ZC_1
    JB BT0,SS_1
    ZC_1: CLR P2.2
    MOV P0,A
    SS_1: LCALL DELAY1
    SETB P2.2
    MOV A,B
    MOV DPTR,#DEG2
    MOVC A,@A+DPTR
    CJNE R2,#01H,ZC_2
    JB BT0,SS_2
    ZC_2: CLR P2.3
    MOV P0,A
    SS_2: LCALL DELAY1
    SETB P2.3
    MOV A,MINUTE
    MOV B,#0AH
    DIV AB
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CJNE R2,#02H,ZC_3
    JB BT0,SS_3
    ZC_3: CLR P2.4
    MOV P0,A
    SS_3: LCALL DELAY1
    SETB P2.4
    MOV A,B
    MOV DPTR,#DEG2
    MOVC A,@A+DPTR
    CJNE R2,#02H,ZC_4
    JB BT0,SS_4
    ZC_4: CLR P2.5
    MOV P0,A
    SS_4: LCALL DELAY1
    SETB P2.5
    MOV A,SECOND
    MOV B,#0AH
    DIV AB
    MOV DPTR,#DEG1
    MOVC A,@A+DPTR
    CJNE R2,#03H,ZC_5
    JB BT0,SS_5
    ZC_5: CLR P2.6
    MOV P0,A
    SS_5: LCALL DELAY1
    SETB P2.6
    MOV A,B
    MOVC A,@A+DPTR
    CJNE R2,#03H,ZC_6
    JB BT0,SS_6
    ZC_6: CLR P2.7
    MOV P0,A
    SS_6: LCALL DELAY1
    SETB P2.7
    RET
    ;键判子程序
    JIANPAN: JB SHEZHI1,TAIQI_
    JB ANJIAN6,TAIQI_
    SETB ANJIAN6
    INC R2
    CJNE R2,#03H,TAIQI_
    MOV R2,#01H
    TAIQI_: JNB SHEZHI1,PAN1_
    CLR ANJIAN6
    PAN1_: JB JIA,TAIQI2_
    JB ANJIAN2,TAIQI2_
    SETB ANJIAN2
    CJNE R2,#00H,JIAHOUR
    LJMP TAIQI2_
    JIAHOUR:CJNE R2,#01H,JIAMINUTE
    INC HOUR
    LJMP TAIQI2_
    JIAMINUTE: CJNE R2,#02H,TAIQI2_
    INC MINUTE
    TAIQI2_: JNB JIA,PAN2_
    CLR ANJIAN2
    PAN2_: JB JIAN,TAIQI3_
    JB ANJIAN3,TAIQI3_
    SETB ANJIAN3
    CJNE R2,#00H,JIANHOUR
    LJMP TAIQI3_
    JIANHOUR: CJNE R2,#01H,JIANMINUTE
    DEC HOUR
    LJMP TAIQI3_
    JIANMINUTE: CJNE R2,#02H,TAIQI3_
    DEC MINUTE
    TAIQI3_: JNB JIAN,PAN3_
    CLR ANJIAN3
    PAN3_: JB MSURE,TAIQI4_
    JB ANJIAN4,TAIQI4_
    SETB ANJIAN4
    MOV R2,#00H
    TAIQI4_: JNB MSURE,OUT_
    CLR ANJIAN4
    OUT_: RET
    DELAY1: MOV R5,#02H
    DL: MOV R4,#0FFH
    DJNZ R4,$
    DJNZ R5,DL
    RET
    END

  • 相关阅读:
    我眼中的SCRUM
    文本转换程序
    免费接口
    看板,敏捷的另一种实现方式
    Android Asynchronous Http Client-Android异步网络请求客户端接口
    hdu4753 Fishhead’s Little Game 状态压缩,总和一定的博弈
    dbcp、c3p0、jdbc常用连接配置
    IE安全分析
    redis入侵小结
    heartbleed漏洞利用
  • 原文地址:https://www.cnblogs.com/cloudstep/p/1592377.html
Copyright © 2011-2022 走看看