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

          新聞中心

          EEPW首頁 > 手機與無線通信 > 設(shè)計應(yīng)用 > 基于dsPIC33FJ128MC506的CAN通信(07-100)

          基于dsPIC33FJ128MC506的CAN通信(07-100)

          ——
          作者:山東省科學(xué)院自動化研究所 張云 李明強 莊汝科 時間:2009-03-04 來源:電子產(chǎn)品世界 收藏

            寫報文內(nèi)容

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

            /*下面的函數(shù)將待發(fā)報文內(nèi)容寫入到發(fā)射緩沖區(qū),各參數(shù)含義如下:

            buf -> 發(fā)射緩沖器號

            dataLength -> 數(shù)據(jù)的長度

            data1/data2/data3/data4 -> 發(fā)射數(shù)據(jù)內(nèi)容*/

            void ecan1WriteTxMsgBufData(unsigned int buf, unsigned int dataLength, unsigned int data1, unsigned int data2, unsigned int data3, unsigned int data4)

            {

            ecan1msgBuf[buf][2] = ((ecan1msgBuf[buf][2] & 0xFFF0) + dataLength) ;//數(shù)據(jù)長度

            ecan1msgBuf[buf][3] = data1; //數(shù)據(jù)1

            ecan1msgBuf[buf][4] = data2; //數(shù)據(jù)2

            ecan1msgBuf[buf][5] = data3; //數(shù)據(jù)3

            ecan1msgBuf[buf][6] = data4; //數(shù)據(jù)4

            }

            報文的接收

            報文接收在中斷中進行,函數(shù)語句如下:

            void __attribute__((interrupt, no_auto_psv))_C1Interrupt(void) //1中斷

            {

            IFS2bits.C1IF = 0; //請中斷標(biāo)志

            if(C1INTFbits.TBIF) //是否為發(fā)射中斷

            {

            C1INTFbits.TBIF = 0;

            }

            if(C1INTFbits.RBIF) //是否為接收中斷

            {

            C1INTFbits.RBIF = 0; //請接收中斷標(biāo)志位

            /*讀出報文*/

            ReceiveMessageID = (ecan1msgBuf[2][0]>>2);

            ReveiveDataLength = (ecan1msgBuf[2][2]&0x000f);

            ReceiveData[0] = ecan1msgBuf[2][3];

            ReceiveData[1] = ecan1msgBuf[2][4];

            ReceiveData[2] = ecan1msgBuf[2][5];

            ReceiveData[3] = ecan1msgBuf[2][6];

            C1RXFUL1bits.RXFUL2 = 0; //清報文溢出標(biāo)志

            ReceiveNewMessage = 1; //接收標(biāo)志置位

            }

            C1RXOVF1bits.RXOVF2 = 0;

            }



          關(guān)鍵詞: CAN TJA1054 dsPIC33FJ128MC506

          評論


          技術(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); })();