<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于MCS-51單片機(jī)的智能時鐘控制系統(tǒng)設(shè)

          基于MCS-51單片機(jī)的智能時鐘控制系統(tǒng)設(shè)

          作者: 時間:2012-10-29 來源:網(wǎng)絡(luò) 收藏

          本文引用地址:http://www.ex-cimer.com/article/170726.htm

          ……

          ;**************************; 以下為主程序 (檢測各鍵是否按下)
          ;***************************MainLoop:
          jb AlarmSetKey,CheckMinuteKey
          call Delay
          jb AlarmSetKey,CheckMinuteKey
          setb ClockMode
          call AlarmSet
          CheckMinuteKey:
          jb MinuteKey,CheckHourKey
          mov a,Minute
          add a,#1
          mov Minute,a
          cjne a,#3ch,NotOver1
          mov Minute,#0
          NotOver1:
          jnb MinuteKey,$
          CheckHourKey:
          jb HourKey,CheckAlarmA
          mov a,Hour
          add a,#1
          mov Hour,a
          cjne a,#18h,NotOver2
          mov Hour,#0
          NotOver2:
          jnb HourKey,$
          CheckAlarmA:
          jnb AlarmTimeOnA,CheckAlarmP
          call StartPc; call AlarmProcess
          ajmp ToReturn
          CheckAlarmP:
          jnb AlarmTimeOnP,ToReturn
          call ShutPc
          ToReturn:
          ajmp MainLoop
          ;**************************; 定時器Timer0中斷服務(wù)程序(此程序每8ms執(zhí)行一次)
          ;***************************
          TimeInt:
          mov th0,#0E0h
          mov tl0,#0bfh
          push acc
          push psw
          SETB rs0
          clr rs1
          d jnz OneSecondCounter,NotoneSecond
          mov OneSecondCounter,#125
          call Clock
          call ConvertoBuffer
          NotoneSecond:
          call ScanDisplay
          pop psw
          pop acc
          reti
          ; ***************************
          ; 掃描顯示子程序
          ;***************************
          ScanDisplay:
          mov r1,#DisplayBuffer
          mov R4,#11111011b
          play:
          mov a,R4
          mov P2,A
          mov A,@R1
          mov DPTR,#TAB
          movc A,@A+DPTR
          mov P0,A
          lcall Delay
          inc R1
          mov A,R4
          jnb ACC.7,ENDOUT
          rl A
          mov R4,A
          ajmp PLAY
          endout: SETB P2.7
          mov P0,#0FFH ret
          TAB:DB 0C0H,0F9H,0A4H,0B0H,
          99H,92H,82H,0F8H,80H,90H,7FH,
          0B7H,0FFH
          ;***************************
          ; 內(nèi)容加1秒的子程序
          ;***************************
          Clock:
          mov a,Second
          add a,#1
          mov Second,a
          cjne a,#3cH,NotOverFlow
          mov Second,#0
          mov a,Minute
          add a,#1
          mov Minute,a
          cjne a,#3cH,NotOverFlow
          mov Minute,#0
          mov a,Hour
          add a,#1
          mov Hour,a
          cjne a,#18H,NotOverFlow
          mov Hour,#0
          NotOverFlow:
          mov a,Second
          jnz NotAlarm
          jnb AlarmAOnOff,PAlarm
          mov a,Minute
          cjne a,AlarmAMinute,PAlarm
          mov a,Hour
          cjne a,AlarmPHour,PAlarm
          ajmp alarming
          PAlarm:
          jnb AlarmPOnOff,NotAlarm
          mov a,Minute
          cjne a,AlarmPMinute,NotAlarm
          mov a,Hour
          cjne a,AlarmPHour,NotAlarm
          ajmp Alarming1
          Alarming:
          setb AlarmTimeOnA
          ajmp NotAlarm
          Alarming1:
          setb AlarmTimeOnP;
          NotAlarm:
          ret
          ;***************************
          ; 將內(nèi)容或鬧時設(shè)置值轉(zhuǎn)換到顯示緩沖區(qū)子程序
          ;***************************
          ConvertoBuffer:
          mov r1,#DisplayBuffer
          jb ClockMode,DispAlarmSet
          mov a,Second
          mov DispSecond,a
          mov a,Minute
          mov Dispminute,a
          mov a,Hour
          mov DispHour,a
          ajmp Convert
          DispAlarmSet:
          jb AlarmAOnOff,AlarmAOn
          mov DispSecond,#00h
          jb AlarmPOnOff,AlarmPOn
          mov DispSecond,#00h
          ajmp Convert
          AlarmAOn:
          mov DispSecond,#11
          NextA:
          mov a,AlarmAMinute
          mov Dispminute,a
          mov a,AlarmAHour
          mov DispHour,a
          ajmp Convert
          AlarmPOn:
          mov DispSecond,#11
          NextP:
          mov a,AlarmPMinute
          mov Dispminute,a
          mov a,AlarmPHour
          mov DispHour,a
          Convert:
          mov a,DispSecond
          mov b,#10
          div ab
          mov @r1,b
          inc r1
          mov @r1,a
          inc r1
          mov a,DispMinute
          mov b,#10
          div ab
          mov @r1,b
          inc r1
          mov @r1,a
          inc r1
          mov a,DispHour
          mov b,#10
          div ab
          mov @r1,b
          inc r1
          mov @r1,a
          ret


          結(jié)束語

          ,以AT89C51微處理器為核心,具有集成度高、性能穩(wěn)定、抗干擾能力強(qiáng)、性價比高的優(yōu)點。經(jīng)軟件仿真和實際功能驗證,證明設(shè)計可靠、設(shè)計方案可行,在實際應(yīng)用中有較大的實 用價值。


          上一頁 1 2 下一頁

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();