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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 用AVR單片機模擬的串口程序

          用AVR單片機模擬的串口程序

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

          >>>>>>>>>>>>>>>>>>>>>>>>>>
          ;receivestart1bitdata8bitstop1bit
          timer0_receive:
          cpibit_cnt,1;ifbit_cnt=1thenstartbit
          breqtimer0_receive_start
          cpibit_cnt,10;ifbit_cnt=10thenstopbit
          breqtimer0_receive_stop

          rjmptimer0_receive_data
          timer0_receive_start:
          sbispind,rxd0
          rjmptimer0_end

          cbrstatus,(1rdr);startbitwrongthenrdr=0exit
          rjmptimer0_complete
          timer0_receive_data:
          sec
          sbispind,rxd0;getrxd0data
          clc
          rorsbuf0
          rjmptimer0_end
          timer0_receive_stop:
          cbrstatus,(1fe0);ifstopbit=0thenfe0=0
          sbispind,rxd0
          rjmptimer0_complete
          sbrstatus,(1fe0)
          sbrstatus,(1rdr);rdr=1
          ;>>>>>>>>>>>>>>>>>>>>>>>>>>
          timer0_complete:
          intemp,timsk
          cbrtemp,(1toie0)
          outtimsk,temp;disabletimsk/toie0
          ;;;;;;;;;;;;;;;;;;;
          intemp,gifr
          sbrtemp,(1intf0)
          outgifr,temp;clrint0flag

          intemp,gimsk
          sbrtemp,(1int0)
          outgimsk,temp;enablegimsk/int0

          cbrstatus,(1busy)|(1td);busy=0,td=0
          timer0_end:
          poptemp
          outsreg,temp
          poptemp

          reti
          ;******************************************
          int00:
          pushtemp
          intemp,sreg
          pushtemp

          lditemp,(256-N/2);skip0.5bit
          outTCNT0,temp

          ldistatus,(1busy);busy=1,rdr=0,td=0,fe0=0
          clrbit_cnt

          intemp,tifr
          sbrtemp,(1tov0)
          outtifr,temp;clrtifr/tov0

          intemp,timsk
          sbrtemp,(1toie0)
          outtimsk,temp;enabletimsk/toie0

          intemp,gimsk
          cbrtemp,(1int0)
          outgimsk,temp;disablegimsk/int0

          poptemp
          outsreg,temp
          poptemp
          reti
          ;**********************************************************

          rxd0_data:
          txd0_data:
          ldistatus,(1busy)|(1td);busy=1,td=1,rdr=0

          pushtemp
          intemp,gimsk
          cbrtemp,(1int0)
          outgimsk,temp;disablegimsk/int0
          poptemp

          serbit_cnt;bit_cnt=0xff
          movsbuf0,temp;senddata

          lditemp,(256-N)
          outTCNT0,temp;wait1bittimer0interrupt

          intemp,tifr
          sbrtemp,(1tov0)
          outtifr,temp;clrtifr/tov0

          intemp,timsk
          sbrtemp,(1toie0)
          outtimsk,temp;enabletimsk/toie0

          cbiportb,txd0;uartstart

          ret
          ;******************************************
          rxd0_data:
          sbrsstatus,fe0;iffe0=0thenexit
          rjmprxd0_data_end
          cbrstatus,(1rdr);rdr=0
          movtemp,sbuf0
          rxd0_data_end:
          ret
          ;******************************************

          ;uartreceivedabytsfromuartandthenreturnitfromuart0:
          ;uartreceivedabytsfromuart0andthenreturnitfromuart:
          main:
          sbicusr,rxc
          rjmpsend_115200

          sbrsstatus,rdr
          rjmpuart_end
          send_19200:
          rcallrxd0_data;getuartdatafrom19200bpsuart0

          wait2:sbisusr,udrie
          rjmpwait2
          outudr,temp;senddatato115200bpsuart
          rjmpuart_end

          send_115200:
          intemp,udr;getuartdatafrom115200bpsuart
          sbicusr,fe
          rjmpuart_end;iffeerrthenend

          wait3:sbrcstatus,td;waitsendflag
          rjmpwait3
          rcalltxd0_data;senddatato19200bpsuart0
          uart_end:
          rjmpmain
          ;**********************************************************
          .exit
          ;**********************************************************


          上一頁 1 2 下一頁

          關(guān)鍵詞: AVR單片機 串口程序 模擬

          評論


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