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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > avr can芯片使用

          avr can芯片使用

          作者: 時間:2016-11-29 來源:網(wǎng)絡 收藏
          #include
          struct MOb{unsigned long id;unsigned char data [8];};void can_init (void);void can_tx (struct MOb msg);void can_rx (struct MOb msg);void can_init (void){unsigned char i,j;//reset CAN interfaceCANGCON |= (1< baudrate// bit timing -> datasheet 264 (check table)// 250Kbps 16MHz cpu-clkCANBT1 = 0x0E;//16M/8=2MCANBT2 = 0x04;//3QTCANBT3 = 0x13;//2+2=4// clear CAN interrupt registersCANGIE = 0; // none interruptsCANIE1 = 0; // none interrupts on MObsCANIE2 = 0;CANSIT1 = 0;CANSIT2 = 0;//start CAN interfaceCANGCON = (1<<1);//wait until module readywhile (!(CANGSTA & (1<>8);CANIDT2 = (unsigned char) (msg.id>>16);CANIDT1 = (unsigned char) (msg.id>>24);//put data in mailboxfor (i=0; i<8; i++)CANMSG = msg.data [i];//enable transmissionCANCDMOB |= (1<> 5);CANIDT2 = (unsigned char)(msg.id >> 13);CANIDT1 = (unsigned char)(msg.id >> 21);// set mask in order to receive only the message with the IDCANIDM4 = 248;CANIDM3 = 255;CANIDM2 = 255;CANIDM1 = 255;// enable extended IDCANIDM4 |= (1<>= 3;}


          關鍵詞: avrcan芯

          評論


          技術專區(qū)

          關閉
          看屁屁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); })();