温湿度监控装置汇编语言源程序清单.doc_第1页
温湿度监控装置汇编语言源程序清单.doc_第2页
温湿度监控装置汇编语言源程序清单.doc_第3页
温湿度监控装置汇编语言源程序清单.doc_第4页
温湿度监控装置汇编语言源程序清单.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

温湿度监控装置汇编语言源程序清单.doc;*WDAT DATA 40H RDAT DATA 41HLdata DATA 42HHdata DATA 43HP0M1 DATA 84HP0M2 DATA 85HP1M1 DATA 91HP1M2 DATA 92HP2M1 DATA 0A4HP2M2 DATA 0A5HTRIM DATA 96HSSTAT DATA 0BAH IEN0 DATA 0A8HIEN1 DATA 0E8HWDL DATA 0C1HWFEED1 DATA 0C2HWFEED2 DATA 0C3HWDCON DATA 0A7HFMCON DATA 0E4HFMDATA DATA 0E5HFMADRL DATA 0E6HFMADRH DATA 0E7H SPSTAT DATA 0E1HSPCTL DATA 0E2HSPDAT DATA 0E3HRTCCON DATA 0D1HRTCH DATA 0D2HRTCL DATA 0D3H; 定义FLASH控制命令字;*LOAD EQU 00H ; 加载数据PROG EQU 48H ; 编程ERS_PROG EQU 68H ; 擦除编程 ERS_S EQU 71H ; 擦除扇区ERS_P EQU 70H ; 擦除页AN1 BIT P1.5 ;按扭1AN2 BIT P1.3 ;按扭2AN3 BIT P1.2 ;按扭3Read_P BIT P1.4 ;读数据口out BIT P0.0 ;负载输出 ;-变量定义区-;* FLAG EQU 63H U8comdata EQU 64H U8T_data_H EQU 65H U8T_data_L EQU 66H U8RH_data_H EQU 6AH U8RH_data_L EQU 6BH U8checkdata EQU 6CH U8temp EQU 6DH temp EQU 6EH ;* ORG 0000H AJMP INIT_0 ORG 000BH LJMP T0ZD ORG 001BH LJMP T1ZD ORG 0023H LJMP CYKZD ORG 0053H LJMP RTCI ORG 0060H DB 0FCH DB 60H DB 0DAH DB 0F2H DB 66H DB 0B6H DB 0BEH DB 0E0H DB 0FEH DB 0F6H DB 1CH ;L DB 6EH ;H DB 00H ;消隐 DB 00H DB 00H DB 1AH ;c DB 0BCH ;G DB 3AH ;o DB 7AH ;d DB 2EH ;h DB 9EH ;E;* ORG 0080HINIT_0: MOV 22H,#03H MOV 25H,#00H MOV 2AH,#00H MOV 2DH,#00H MOV 2CH,#00H MOV 30H,#00H MOV 31H,#00H MOV 32H,#00H MOV 33H,#00H MOV 34H,#00H MOV 35H,#00H MOV 3DH,#35H MOV 42H,#09H MOV 43H,#01H MOV 45H,#00H MOV 46H,#00H MOV 47H,#00H MOV 48H,#00H MOV 49H,#00H MOV 4BH,#0FH MOV 4CH,#02H MOV 4DH,#0FH MOV 50H,#00H MOV 51H,#0BCH MOV 52H,#3AH MOV 53H,#3AH MOV 54H,#7AH MOV 55H,#00H MOV 5BH,#5 MOV 5DH,#58H MOV P0M1,#00H MOV P0M2,#3DH MOV P1M1,#20H MOV P1M2,#03H MOV P1,#0FFH MOV TCON,#05H;#55H MOV TMOD,#11H MOV SCON,#00H;#10H ;MOV TL0,#0B4H ;MOV TH0,#3CH MOV TL1,#88H MOV TH1,#98H MOV RTCL,#7FH MOV RTCH,#70H MOV RTCCON,#63H MOV IEN0,#0DAH INIT_2: MOV Acc,WDCON SETB Acc.2 MOV WDL,#0FFH CLR EA MOV WDCON,Acc MOV WFEED1,#0A5H MOV WFEED2,#5AH SETB EA INIT_3: MOV 2EH,#00H MOV 2FH,#00H MOV DPTR,#7F1H LCALL RFLASH MOV 31H,RDAT MOV DPTR,#7F2H LCALL RFLASH MOV 32H,RDAT MOV DPTR,#7F6H LCALL RFLASH MOV 26H,RDAT;*MAIN: CLR 2AH ;温度/湿度切换标志位 CLR 58H ;控制信号“开”辅助位 CLR 59H ;读取数据辅助位 SETB 5AH ;FLASH读写辅助位 CLR 5BH ;转换限制辅助位 CLR 5CH ;中继数据保存辅助位 CLR 5DH ;75ms中断延时辅助位 CLR 5EH ;手控开/关辅助位 CLR 7BH ;闪烁辅助位 CLR out ;负载输出 SETB Read_P; MOV R4,#00H LCALL WDT_R LJMP LOOP0KSM00: LJMP KSM0 LOOP0: MOV R1,#53H;#51H MOV R2,#20H;#01H MOV R3,#04HLOOP1: MOV DPH,#00H MOV DPL,#60H MOV A,R1 MOVC A,A+DPTR JNB 6FH, LOOP2 ADD A,#01H CLR 6FHLOOP2: MOV SBUF,A MOV A,P0 ANL A,#03H ORL A,R2 JNB 55H, SSCL JB 7BH, SSCL0 JNB 50H, SSCLSSCL0: ANL A,7BHSSCL: MOV P0,A MOV A,R2 RR A;RL A MOV R2,A ANL A,#3CH CJNE A,#04H, GPPP SETB 6FHGPPP: JNB AN1, KSM00 JNB AN2, KSM00 JNB AN3, KSM00 JNB 72H, ABC ANL 2EH,#00H CLR 72HABC: JB 59H, DEF JB 60H, DEF LCALL Read_WS SETB 59H LCALL OperationDEF: NOP LOOP3: JNB 55H, LOOP4 JB 7BH, XY5 JNB 50H, LOOP4 JB 51H, XY1 JB 52H, XY2 JB 53H, XY3 JB 54H, XY6 JB 56H, XY6 LOOP4: LCALL DELLY JB 50H, GPPPP JB 67H, GPPPP MOV A,R2 JB ACC.3, GPPPPP GPPPP: NOP GPPPPP: NOP LOOP5: JB 28H, LOOP6 JB 60H, LOOP7 JB 65H, LOOP7 LOOP6: JNB 29H, LOOP7 NOPLOOP7: DEC R1;INC R1 DJNZ R3, LOOP10 LCALL WDT_R JNB 72H, LOOP8 JB 76H, JSLOOP8: JB 28H, LOOP00 JB 60H, LOOP00 JNB 7DH, LOOP00 LOOP00: LJMP LOOP0 LOOP10: LJMP LOOP1 XY1: MOV 7BH,#0DFH LJMP LOOP4XY2: MOV 7BH,#0EFH LJMP LOOP4XY3: MOV 7BH,#0F7H LJMP LOOP4XY5: MOV 7BH,#0C3H LJMP LOOP4XY6: MOV 7BH,#0CFH LJMP LOOP4 JS: DJNZ 5DH, LOOP00 JNB 60H, LOOP00 ; CLR 76H MOV 5DH,#25H LJMP LOOP0 LJMP LOOP7 KSM0: JB 75H, LOOP30 JB 76H, LOOP30 JB 77H, KSM1 MOV TL0,#0EBH MOV TH0,#0E0H MOV 67H,#26H MOV 5DH,#55H MOV 48H,#00H MOV 49H,#00H CLR 2FH SETB TCON.4 SETB 75HLOOP30: LJMP LOOP3KSM1: JB 72H, KSM2 JB 76H, LOOP30KSM2: ;SETB 70H ;SETB 73H SETB 76H JNB AN1, KJSGN JNB AN2, KJSYW0 JNB AN3, KJSZL0 LJMP LOOP3 KJSZL0: LJMP KJSZLKJSYW0: LJMP KJSYW LJMP INIT_3KJSGN: JB 60H, KJSGN10 JB 50H, KJSGN10 SETB 7EH DJNZ 22H, LOOP33 CLR 67H CLR 66H SETB 60H CLR 28H MOV 22H,#03H MOV 2AH,#03H MOV 2CH,#03H MOV R4,#01H MOV 78H,31H LCALL HEX_BCDBLOCK MOV 50H,#0AH LOOP33: LJMP LOOP3 KJSGN10: LJMP KJSGN1GN0: LCALL BCD_HEXBLOCK JB 61H, WT1 JB 62H, WT2 JB 63H, SWTCH ANL 2CH,#3FH LJMP LOOP3 WT1: MOV A,#7DH ;#50H CJNE A,5FH, WT11WT110: MOV A,#05H ; ADD A,5FH CJNE A,32H, WT112WT111: MOV 31H,5FH CLR 7AH MOV DPTR,#7F1H MOV WDAT,5FH;#58H LCALL WFLASH LJMP GNJSWT112: JNC FMCL LJMP WT111 WT11: JC FMCL MOV A,5FH CJNE A,#00H, WT12 LJMP WT111WT12: JC FMCL LJMP WT110 WT2: MOV A,#7DH; CJNE A,5FH, WT21 LJMP WT211WT21: JC FMCL MOV A,#05H ADD A,31H CJNE A,5FH, WT22 LJMP WT211 MOV A,5FH CJNE A,#00H, WT21 WT210: MOV A,#05H ADD A,31H CJNE A,5FH, WT212WT211: MOV 32H,5FH CLR 7AH MOV DPTR,#7F2H MOV WDAT,5FH;#58H LCALL WFLASH LJMP GNJSWT212: JC FMCL LJMP WT211 WT22: JNC FMCL LJMP WT211SWTCH: CLR 7AH MOV DPTR,#7F6H MOV WDAT,26H;#58H LCALL WFLASH LJMP GNJSFMCL: SETB 7AH LJMP LOOP3 GN00: LJMP GN0 KJSGN1: JB 66H, GN00 JB 67H, GN00 CLR 7AH INC R4 GNJS: CJNE R4,#00H, GNL MOV 2AH,#00H MOV 2CH,#00H LCALL Operation MOV 50H,#0FH LJMP LOOP3GNL: CJNE R4,#01H, GNH MOV 2AH,#03H MOV 2CH,#03H MOV 50H,#0AH MOV 78H,31H LCALL HEX_BCDBLOCK LJMP LOOP3GNH: CJNE R4,#02H, GNS MOV 2AH,#03H MOV 2CH,#05H MOV 50H,#0BH MOV 78H,32H LCALL HEX_BCDBLOCK LJMP LOOP3 GNS: CJNE R4,#03H, GNFW MOV 2AH,#41H MOV 2CH,#09H MOV 50H,#05H JNB 35H, GNSa MOV 51H,#0CH MOV 52H,#0FH MOV 53H,#11H LJMP LOOP3GNSa: MOV 51H,#0CH MOV 52H,#0BH MOV 53H,#14H LJMP LOOP3 GNFW: MOV R4,#00H MOV 2AH,#00H MOV 2CH,#00H MOV 2DH,#00H ;MOV 51H,R6 LJMP GNJS KJSYW: JB 65H, LOOP35 JB 67H, LOOP35 SETB 66HJB 63H, KJSQH JNB 50H, KJSYW1 CLR 28H JB 51H, YW1 JB 52H, YW2 JB 53H, YW3 LJMP LOOP3KJSYW1: CPL 5EH MOV 2AH,#00H ;MOV 2CH,#00H JNB 5EH, KJSYW2SETB out SETB 7BH MOV 49H,#00H LJMP LOOP3KJSYW2: MOV 7BH,#0FFH CLR out CLR 7BH LJMP LOOP3YW1: MOV 2AH,#05H LJMP LOOP3YW2: MOV 2AH,#09H LJMP LOOP3YW3: MOV 2AH,#03HLOOP35: LJMP LOOP3 KJSQH: CPL 35H JNB 35H, KJSQH1 MOV 51H,#0CH MOV 52H,#0FH MOV 53H,#11H LJMP LOOP3KJSQH1: MOV 51H,#0CH MOV 52H,#0BH MOV 53H,#14H LJMP LOOP3KJSZL: JB 63H, LOOP35 JB 65H, LOOP35 SETB 66H;67H JB 51H, GWDJ JB 52H, SWDJ JB 53H, BWDJ LJMP RH_TGWDJ: INC 53H MOV A,53H CJNE A,#0AH, LOOP35 MOV 53H,#00H LJMP LOOP3SWDJ: INC 52H MOV A,52H CJNE A,#0AH, LOOP35 MOV 52H,#00H LJMP LOOP3BWDJ: INC 51H MOV A,51H CJNE A,#01H, B555 MOV 51H,#01H LJMP LOOP3B555: MOV 51H,#00H LJMP LOOP3 RH_T: CPL 2AH LJMP LOOP3;*DELLY: MOV R7,#1FHMS2: MOV R6,#5FHMS1: DJNZ R6,MS1 DJNZ R7,MS2 RET ;* WDT_R: CLR EA MOV WFEED1,#0A5H MOV WFEED2,#5AH SETB EA RET ;* T0ZD: PUSH Acc PUSH PSW CLR 75H SETB 77H SETB 72H CLR TCON.4 FW0: POP PSW POP Acc RETI ;* T1ZD: PUSH Acc PUSH PSWCLR TCON.7SETB 5DH MOV TH1,#00HMOV TL1,#01H CLR TCON.6 FW1: POP PSW POP Acc RETI ;*RTCI: PUSH Acc PUSH PSW ANL RTCCON,#63HINC 5BHCPL 55H;CLR 59H DJNZ 67H, SZ0 MOV 2DH,#00H MOV 2CH,#00H MOV 2AH,#00H MOV 22H,#03H MOV 67H,#26H CLR 25H CLR 73HSZ0: INC 45H MOV A,45H CJNE A,#03H, FWR MOV 45H,#00HCLR 59H FWR: POP PSW POP Acc RETI;* CYKZD: PUSH Acc PUSH PSW ANL SCON,#0FCH NOP POP PSW POP Acc RETI;写字节数据;*WFLASH: CLR EA MOV FMCON,#LOAD MOV FMADRH,DPH MOV FMADRL,DPL MOV FMDATA,WDAT; MOV FMCON,#ERS_PROG; MOV A,FMCON ANL A,#0FH SETB 5AH JZ WFLASHF CLR 5AH WFLASHF:SETB EA RET; 读字节数据;*RFLASH: CLR A MOVC A,A+DPTR MOV RDAT,A RET ;采集温湿度数据;*Read_WS:;- ;主机拉低总线,延时500us CLR Read_P MOV A,#1 LCALL Delay;LCALL Delay;LCALL DelayLCALL DelayLCALL Delay SETB Read_P ;延时40us LCALL Delay_10us LCALL Delay_10us LCALL Delay_10us LCALL Delay_10us ;检测从机是否响应,无响应则跳出 JB Read_P,RH_END MOV FLAG,#0LOOPA: INC FLAG MOV A,FLAG JB Read_P,LOOPA_END ;为高电平则跳出 CJNE A,#0,LOOPA LJMP RH_ENDLOOPA_END: MOV FLAG,#0LOOPB: INC FLAG MOV A,FLAG JNB Read_P,LOOPB_END ;为低电平则跳出 CJNE A,#0,LOOPB LJMP RH_ENDLOOPB_END: ;进入数据接收阶段 LCALL Read MOV U8RH_data_H,U8comdata; LCALL Read MOV U8RH_data_L,U8comdata; LCALL Read MOV U8T_data_H,U8comdata; LCALL Read MOV U8T_data_L,U8comdata; LCALL Read MOV U8checkdata,U8comdata; SETB Read_PRH_END: RET;-读数子程序-;*Read: MOV temp,#8 MOV U8comdata,#0LOOP_COM: MOV FLAG,#0LOOPC: INC FLAG MOV A,FLAG JB Read_P,LOOPC_END CJNE A,#0,LOOPC LJMP COM_ENDLOOPC_END: LCALL Delay_10us LCALL Delay_10us LCALL Delay_10us MOV U8temp,#0 JNB Read_P,HIGH_END MOV U8temp,#1HIGH_END: MOV FLAG,#0LOOPD: INC FLAG MOV A,FLAG JNB Read_P,LOOPD_END CJNE A,#0,LOOPD LJMP COM_ENDLOOPD_END: MOV A,FLAG CJNE A,#0,NO_FLAG LJMP COM_EN

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论