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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 雙核單片機(jī)紅外遙控碼代碼

          雙核單片機(jī)紅外遙控碼代碼

          作者: 時(shí)間:2011-12-01 來源:網(wǎng)絡(luò) 收藏
          一個(gè)用應(yīng)廣做的紅外遮擋開光(反射式)全部代碼。

          IR_SW equ pb.1
          IR_INPUT equ pa.0
          IR_OUTPUT equ pa.6


          byte ir_new
          byte ir_old
          byte ir_enable
          byte i
          byte ir_new1
          byte ir_new2
          byte ir_new3

          goto main0
          goto main1

          //----------------FPPA0-------------------
          main0:
          .ADJUST_OTP_IHRCR 8MIPS// IHRC/2 = 8MIPS, WatchDog Disable, RAM 0,1 temporary be used

          sp = 0x30

          disgint
          inten = 0

          mov a,0b000_11_111 //disable timer
          mov t16m,a

          set1 pbc.1
          set0 IR_SW

          set0 pac.0
          set1 pac.6
          set0 IR_OUTPUT

          delay 200

          ir_new = 0
          ir_old = 0
          ir_enable = 0

          mov a,0
          mov intrq,a


          set1 fppen.1 //eanble FPPA1

          ir_enable = 1
          i = 20
          while(i)
          {
          delay 200
          i--
          }

          if(IR_INPUT)
          {
          ir_old = 1
          }
          else
          {
          ir_old = 0
          }

          ir_enable = 0
          i = 5
          while(i)
          {
          delay 200
          i--
          }

          clkmd.1 = 1 //enable watch dog


          main0_loop:
          wdreset
          call check_ir

          if(ir_new != ir_old)
          {
          if(ir_new != 1)
          {
          tog IR_SW
          }
          ir_old = ir_new
          }

          i = 100
          while(i)
          {
          delay 200
          i--
          }
          goto main0_loop

          check_ir:
          ir_enable = 1
          i = 20
          while(i)
          {
          delay 200
          i--
          }

          if(IR_INPUT)
          {
          ir_new1 = 1
          }
          else
          {
          ir_new1 = 0
          }

          i = 5
          while(i)
          {
          delay 200
          i--
          }

          if(IR_INPUT)
          {
          ir_new2 = 1
          }
          else
          {
          ir_new2 = 0
          }

          i = 5
          while(i)
          {
          delay 200
          i--
          }

          if(IR_INPUT)
          {
          ir_new3 = 1
          }
          else
          {
          ir_new3 = 0
          }

          if((ir_new1 == ir_new2) (ir_new2 == ir_new3))
          {
          ir_new = ir_new1
          }
          else
          {
          ir_new = ir_old
          }

          ir_enable = 0
          i = 20
          while(i)
          {
          delay 200
          i--
          }
          ret

          //----------------FPPA1-------------------
          main1:
          sp = 0x38
          delay 200
          main1_loop: //output 38k IR signal
          if(ir_enable)
          {
          set1 IR_OUTPUT
          delay 33
          set0 IR_OUTPUT
          delay 67
          }
          else
          {
          set0 IR_OUTPUT
          delay 10
          }
          goto main1_loop


          關(guān)鍵詞: 雙核單片機(jī) 紅外遙控

          評(píng)論


          相關(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); })();