基于dsPIC33FJ128MC506的CAN通信(07-100)
——
/*定义局部变量*/
本文引用地址:http://www.amcfsurvey.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);
}
/*将地址写入发射缓冲器对应的区域 */
ecan1msgBuf[buf][0] = word0;
ecan1msgBuf[buf][1] = word1;
ecan1msgBuf[buf][2] = word2;
}
评论