51/AVR单片机技术驿站!  <在线翻译>     便利工具    特色网址   无弹窗、无插件的绿色站点...  英才招聘   学历查询  喜欢>>收藏我站 

当前位置:首页 > 单片机源码 > 详细内容
1602_LCDAT89S52_18B20实现的温度报警时间可调显示程序
发布时间:2009/5/19  阅读次数:6505  字体大小: 【】 【】【


;下面是显示闹钟值

MOV P1,#11000101B
LCALL ENABLE

MOV DPTR,#LED_DATA
MOV R1,ALARM2_H_H //已经是压缩型BCD码了,,
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM2_H_L //已经是压缩型BCD码了,,
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#MAO
MOV R1,#0;从字串中的第一个开始显示
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM2_M_H //已经是压缩型BCD码了,
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM2_M_L //已经是压缩型BCD码了,,
MOV R0,#1
LCALL DISPLAY

;顺序执行下面的

LOOPPP: JB P0.4,PANP05_2;转判P0.5;;;;;;;;;还没有写此句程序呢后面
LCALL DELAY2S
JB P0.4,ADJ_ALARM_2_H            ;如果一S之后为放开了,其实是在1S前就放开了的,则知道是调闹钟的小时值的
JNB P0.4,$;1S后还未放开,则等,1S后已经放开,则早就放开,所以进行不同操作
CPL ALARM2_ON_OR_OFF;如果一S后还为0则取反ALARM1_ON_OR_OFF标志,关掉闹钟
LJMP ALARM_K1
ADJ_ALARM_2_H:
                    MOV A,ALARM2_H
                    ADD A,#1
                                    DA A
                                    MOV ALARM2_H,A
                                    CJNE A,#24H,ALARM_NEXT_2
                                    MOV A,#0
                                    MOV ALARM2_H,A

ALARM_NEXT_2JMP ALARM_DATACON_DIS_2;跳到先转换数据,再显示

PANP05_2:JB P0.5,PAN03_2; 如果此时P0.5也为1,则转判P0.3
LCALL DELAY2S
JNB P0.5,$;等放开
MOV A,ALARM2_M
                    ADD A,#1
                                    DA A
                                    MOV ALARM2_M,A
                                    CJNE A,#60H,ALARM_NEXT_2
                                    MOV A,#0
                                    MOV ALARM2_M,A

                             LJMP ALARM_DATACON_DIS_2
PAN03_2:            JB P0.3,LOOPPP
                        LCALL DELAY2S
              JB P0.3,DISPLAY_ALARM3            ;如果一S之后为放开了,其实是在1S前就放开了的,则知道是设闹钟2
              JNB P0.3,$;
                        LJMP BACKK;如果长久按P0.3则跳出到主程序中去

;下面是设置第三个闹钟

DISPLAY_ALARM3:

                LCALL DISPLAY_ALARM_CLOCK_3

ALARM_K2:JB ALARM3_ON_OR_OFF,DISPLAY__ON_3
                        LCALL DISPLAY_ALARM_OFF
                        LJMP ALARM_DATACON_DIS_3
DISPLAY__ON_3:LCALL DISPLAY_ALARM_ON

ALARM_DATACON_DIS_3:
MOV A,ALARM3_H
SWAP A
ANL A,#0FH
MOV ALARM3_H_H,A
MOV A,ALARM3_H
ANL A,#0FH
MOV ALARM3_H_L,A

MOV A,ALARM3_M
SWAP A
ANL A,#0FH
MOV ALARM3_M_H,A
MOV A,ALARM3_M
ANL A,#0FH
MOV ALARM3_M_L,A


;下面是显示闹钟值

MOV P1,#11000101B
LCALL ENABLE

MOV DPTR,#LED_DATA
MOV R1,ALARM3_H_H //已经是压缩型BCD码了
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM3_H_L //已经是压缩型BCD码了,,
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#MAO
MOV R1,#0;从字串中的第一个开始显示
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM3_M_H //已经是压缩型BCD码了,
MOV R0,#1
LCALL DISPLAY

MOV DPTR,#LED_DATA
MOV R1,ALARM3_M_L //已经是压缩型BCD码了
MOV R0,#1
LCALL DISPLAY

;顺序执行下面的

LOOPPPP: JB P0.4,PANP05_3;转判P0.5;;;;;;;;;还没有写此句程序呢后面
LCALL DELAY2S
JB P0.4,ADJ_ALARM_3_H            ;如果一S之后为放开了,其实是在1S前就放开了的,则知道是调闹钟的小时值的
JNB P0.4,$;1S后还未放开,则等,1S后已经放开,则早就放开,所以进行不同操作
CPL ALARM3_ON_OR_OFF;如果一S后还为0则取反ALARM1_ON_OR_OFF标志,关掉闹钟
LJMP ALARM_K2
ADJ_ALARM_3_H:
                    MOV A,ALARM3_H
                    ADD A,#1
                                    DA A
                                    MOV ALARM3_H,A
                                    CJNE A,#24H,ALARM_NEXT_3
                                    MOV A,#0
                                    MOV ALARM3_H,A

ALARM_NEXT_3:LJMP ALARM_DATACON_DIS_3;跳到先转换数据,再显示

PANP05_3:JB P0.5,PAN03_3; 如果此时P0.5也为1,则转判P0.3
           LCALL DELAY2S
JNB P0.5,$;等放开
MOV A,ALARM3_M
                    ADD A,#1
                                    DA A
                                    MOV ALARM3_M,A
                                    CJNE A,#60H,ALARM_NEXT_3
                                    MOV A,#0
                                    MOV ALARM3_M,A

                             LJMP ALARM_DATACON_DIS_3
PAN03_3:            JB P0.3,LOOPPPP
                        LCALL DELAY2S
              JB P0.3,TO_FU6            ;如果一S之后为放开了,其实是在1S前就放开了的,则知道是设闹钟2
              JNB P0.3,$;
                        LJMP BACKK;如果长久按P0.3则跳出到主程序中去
TO_FU6:LJMP FU6
;下面是主程序要调用的比较当前时钟与闹钟值
ALARM_COMPARE:
      JNB ALARM1_ON_OR_OFF,ALARM2_COMPARE
            MOV A,ALARM1_H
            CJNE A,HOUR,ALARM2_COMPARE
            MOV A,ALARM1_M
            CJNE A,MIN,ALARM2_COMPARE
            ;CLR P0.1
           
            ;SETB TEMPERATURE_ALARM_BEEP_FLAG;置位此标志,为1时在后面的CONTROL中SETB P0.1时要考虑此标志为1则不要SETB P0.1了
            CLR ALARM1_ON_OR_OFF

            MOV A,#0
            MOV ALARM1_H,A;响应闹钟后要清0
            MOV ALARM1_M,A
           
            LCALL FU12
LCALL DELAY2S
            MOV A,#0F0H
MOV P2,A
ALARM2_COMPARE:
      JNB ALARM2_ON_OR_OFF,ALARM3_COMPARE
                        MOV A,ALARM2_H
            CJNE A,HOUR,ALARM3_COMPARE
            MOV A,ALARM2_M
            CJNE A,MIN,ALARM3_COMPARE
            ;CLR P0.1
            ;SETB TEMPERATURE_ALARM_BEEP_FLAG
            CLR ALARM2_ON_OR_OFF
            MOV A,#0
            MOV ALARM2_H,A;响应闹钟后要清0
            MOV ALARM2_M,A
            ;此句是后加的,还有下面
            LCALL FU12
LCALL DELAY2S
            MOV A,#0F0H
MOV P2,A
ALARM3_COMPARE:
                JNB ALARM3_ON_OR_OFF,COMPARE_BACK
                        MOV A,ALARM3_H
            CJNE A,HOUR,COMPARE_BACK
            MOV A,ALARM3_M
            CJNE A,MIN,COMPARE_BACK
            ;CLR P0.1
            ;SETB TEMPERATURE_ALARM_BEEP_FLAG
            CLR ALARM3_ON_OR_OFF
            MOV A,#0
            MOV ALARM3_H,A;响应闹钟后要清0
            MOV ALARM3_M,A
           
            LCALL FU12

LCALL DELAY2S
            MOV A,#0F0H
MOV P2,A
COMPARE_BACK:
RET
FU7:
MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序

LCALL DISPLAYINT_STOPWATCH_000000;显示STOPWATCH及----00:00:00----
SETB STOPWATCH_FLAG1;注意在返回主程序前要清0此标志啊;此标志用于开始及暂停
LCALL STOPWATCH_CONTROL;调用判P0.345有无按下
RET;一般是不会自动返回的,只在STOPWATCH_CONTROL中用LJMP 跳回到主程序中继续其它时间温度

RET
FU8:MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_8
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB8_ZHOUXIANGCHUN
LCALL PLAYINGSONG
RET

FU9:MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_9
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB9_SHUIZAIWOSHANG
LCALL PLAYINGSONG     
RET

FU10:    MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_10
LCALL DISPLAY_NAME
MOV DPTR, #MUSIC_TAB10_SHANGAITANG
LCALL PLAYINGSONG
RET

FU11:    MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_11
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB11_GUDANBEI
LCALL PLAYINGSONG
RET

FU12: MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_12
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB12_TAOHUADUODUOKAI
LCALL PLAYINGSONG
RET

FU13:            MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_13
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB13_DACHENXIAAI
LCALL PLAYINGSONG
RET

FU14:MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_14
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB14_QIUFU
LCALL PLAYINGSONG
RET

FU15: MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
LCALL DISPLAYINT_MUSIC
MOV DPTR,#MUSIC_NAME_15
LCALL DISPLAY_NAME
MOV DPTR,#MUSIC_TAB15_JUSTLOVEYOU
LCALL PLAYINGSONG
RET



CONTROL: ;如果28H值在上限值与90度之关,则报警
JB K_ON,CONTROL1;     K_ON的值在数据转换比较下上限温子程序设定
CLR P0.1;超上限温,,则报警,,,而
SETB P3.7;关显示器
;只是在LCD上显示OFF或ON表示机器状态其实在哪可让温报警呢,,在比较的地方可以吧?
AJMP CONTROL_END
CONTROL1:;JB TEMPERATURE_ALARM_BEEP_FLAG,CONTROL2

SETB P0.1
CLR P3.7
;CONTROL2:      CLR P3.7 ;显示器开时是正常工作的
CONTROL_END:
RET
PLAYINGSONG:
LOOP8:CLR A
MOVC A,@A+DPTR
MOV R1,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R0,A
CLR A
INC DPTR
MOVC A,@A+DPTR
MOV R2,A
MOV A,R0
ORL A,R1
JZ STOP8
MOV A,R0
ANL A,R1
CJNE A,#0FFH,NEXT8
EXIT8: CLR TR1
MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
RET

STOP8:CLR TR1
LCALL DELAY
AJMP STOP18
NEXT8: MOV A,#0F0H
          MOV P2,A
                MOV A,P2
                CJNE A,#0F0H,EXIT8
MOV TH1,R1

MOV TL1,R0
SETB TR1

LCALL DELAY
STOP18:INC DPTR
AJMP LOOP8



//**********下面是时间按键及调整程序****************


TIME_ADJ:JNB P0.4,TIME_HOUR
         JNB P0.5,TIME_MIN
               RET

TIME_HOURCALL DELAY2S
               
                           
                           JNB P0.4,$
                           MOV A,HOUR
                           ADD A,#1
                           DA A
                           CJNE A,#24H,TT1
                           MOV A,#0
            TT1:MOV HOUR,A
                    LCALL DATA_CONV1
                        LCALL DISPLAY_TIME
                        JNB P0.4,TIME_HOUR
                        AJMP TIME_ADJ


TIME_MINCALL DELAY2S
                                    JNB P0.5,$
                                    MOV A,MIN
                                    ADD A,#1
                                    DA A
                                    CJNE A,#60H,TT2
                                    MOV A,#0
            TT2:      MOV MIN,A
                         LCALL DATA_CONV1
                             LCALL DISPLAY_TIME
                             JNB P0.5,TIME_MIN
                             AJMP TIME_ADJ

//***********/
;***************键处理程序******************
KEY: SETB 01H;01H是高低温设定标志位    (01H)=1设高限否则设低限
KEY_IN:     ;有键输入的程序
     MOV P1,#00000001B ;清屏并光标复位
    LCALL ENABLE;调用写入命令子程序
    JNB 01H,DSP_SET_L ;01如果是0,则显示L:
DSP_SET_H: ;显示高温的限值
    MOV P1,#10000000B
    LCALL DISPLAY_SETING_TEMP_H ;显示SETING_TEMP:H ..
    MOV DPTR,#LED_DATA
    MOV R1,42H ;码表初值     42H存的是限值哦
    MOV R0,#1;字数
    LCALL DISPLAY
;---------------显示温度限值低位
MOV DPTR,#LED_DATA
MOV R1,41H ;码表初值
MOV R0,#1;字数
LCALL DISPLAY
;---------------显示温度限值低位
MOV DPTR,#LED_DATA
MOV R1,40H ;码表初值
MOV R0,#1;字数
LCALL DISPLAY
AJMP KEY_SELECT

DSP_SET_L:;显示低温的限值
      MOV P1,#10000000B
      LCALL DISPLAY_SETING_TEMP_L ;显示SETING_TEMP ..
      MOV DPTR,#LED_DATA
      MOV R1,45H ;码表初值
      MOV R0,#1;字数
      LCALL DISPLAY
;---------------显示温度限值低位
MOV DPTR,#LED_DATA
MOV R1,44H ;码表初值
MOV R0,#1;字数
LCALL DISPLAY
;---------------显示温度限值低位
MOV DPTR,#LED_DATA
MOV R1,43H ;码表初值
MOV R0,#1;字数
LCALL DISPLAY
AJMP KEY_SELECT

STOPWATCH_CONTROL:JB P0.3,W10.3是控制秒表开始暂停的
                              JNB P0.3,$;等放开
                                                    JNB STOPWATCH_FLAG1,C1;标志为0则开始秒表
                                                    CPL STOPWATCH_FLAG1
                                                    SETB TR2
                                                    
                                                    LJMP STOPWATCH_CONTROL
                                                    W2:JB P0.5,STOPWATCH_CONTROL
     JNB P0.5,$
     CLR TR2
     CLR STOPWATCH_FLAG1;此句重要
     LJMP BACKK;跳出之前要跳到有清屏的地方
                                                C1:CLR TR2
                                                     CPL STOPWATCH_FLAG1
                                                     LJMP STOPWATCH_CONTROL
                                                     W1:JB P0.4,W20.4用于将各单元归0,P0.5 则用于跳回到主程序中但退出前要清屏哦
                                                               JNB P0.4,$
                                                               CLR TR2
                                                               MOV A,#0
                                                               MOV WATCH_H,A
                                                               MOV WATCH_M,A
                                                               MOV WATCH_S,A
                                                               MOV WATCH_MS,A;清0后应该要调用显示一次吧,,让000000显示出来            试试启动TR2看(不行),否则紧接下写显示程序
                                                               ;下面还要调用数据转换哦
                                                                                MOV A,WATCH_H
SWAP A            ;先存的是十位
ANL A,#0FH
MOV WATCH_H_H,A
MOV A,WATCH_H
ANL A,#0FH
MOV WATCH_H_L,A

MOV A,WATCH_M
SWAP A
ANL A,#0FH
MOV WATCH_M_H,A
MOV A,WATCH_M
ANL A,#0FH
MOV WATCH_M_L,A

MOV A,WATCH_S
SWAP A
ANL A,#0FH
MOV WATCH_S_H,A
MOV A,WATCH_S
ANL A,#0FH
MOV WATCH_S_L,A

MOV A,WATCH_MS
MOV B,#10
DIV AB
MOV WATCH_MS_H,A
MOV WATCH_MS_L,B
                                                               ;下面是显示
                                                               MOV P1,#00000001B ;清屏并光标复位
LCALL ENABLE;调用写入命令子程序
;紧接着显示STOPWATCH在上行
MOV P1,#10000000B
LCALL ENABLE
MOV DPTR,#STOPWATCH
MOV R1,#0
MOV R0,#16
LCALL DISPLAY
我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[2]
  • 评论人:[BOBO] 时间: [2011/10/27 16:29:40] IP:[222.89.65.20*]
  • 太厉害了,一定得更加努力。。。。

网站导航 管理登陆 ┊ 免责声明 问题反馈  友链说明
本站部分内容来自网络共享资源,如有冒犯您的权利请来信告之删除或纠正!
不得对本站进行复制、盗链或镜像,转载内容须获得同意或授权;欢迎友情链接、站务合作!

    我要报警 Alexa
 mcusy_cn#126.com (请把#改成@) 交流:522422171
本站学习交流群:138..158(高级群1-)、77930286(高级群2)、61804809(群3)
Copyright© MCUSY All Rights Reserved
本站网警备案号: WZ36040002485
  ICP备案证书号:粤ICP备09034963号