基于dsPIC33FJ128MC506的CAN通信(07-100)
——
/*定義局部變量*/
本文引用地址:http://2s4d.com/article/92042.htmunsigned long word0=0, word1=0, word2=0;
unsigned long sid10_0=0, eid5_0=0, eid17_6=0;
/*賦值*/
eid5_0 = (txIdentifier & 0x7FF);
eid17_6 = (txIdentifier>>6) & 0x7F;
sid10_0 = (txIdentifier>>18) & 0x7FF;
word1 = eid17_6;
if(remoteTransmit==1) // 遠程幀
{
word0 = ((sid10_0 << 2) | ide | 0x2);
word2 = ((eid5_0 << 10)| 0x0200);
}
else { //正常幀
word2 = 0;
word0 = (eid5_0 << 2);
}
/*將地址寫入發(fā)射緩沖器對應(yīng)的區(qū)域 */
ecan1msgBuf[buf][0] = word0;
ecan1msgBuf[buf][1] = word1;
ecan1msgBuf[buf][2] = word2;
}
評論