2407和28335用CAN通信 2407经常出现错误中断 查询CAN错误状态寄存器CANESR为0x80 即 Bit Error Flag
另外 当波特率设置为1M时 会出现 Form Error Flag 的错误
附上2407 CAN的初始化程序
先谢谢了!
void CanInit(void)
{
unsigned int tmp;
CANMDER=0x00;
CANLAM0H=(DOUT_Mask<<2);
CANLAM0L=0xffff;
CANMSGID0H=(DOUT_Add <<2)|0x4000;
CANMSGID0L=0xffff;
CANMBX0A=0;
CANMBX0B=0;
CANMBX0C=0;
CANMBX0D=0;
CANMSGID4H=0x00;
CANMSGID4L=0x00;
CANMSGCTRL4=0x08;
CANMBX4A=0;
CANMBX4B=0;
CANMBX4C=0;
CANMBX4D=0;
CANMCR=0x00;
CANMDER=0x11;
MCRB=MCRB|0x00c0;
CANMCR=0x1000;
do
{
tmp=CANGSR;
WatchDog();
}
while(!(tmp&0x10));
CANBCR2=0x03;
CANBCR1=0x0257;
CANMCR=0x2480;
do
{
tmp=CANGSR;
WatchDog();
}
while(tmp&0x10);
CANIMR=0x117f;
CANIFR=0xffff;
return;
}
Eason Wang:
C2000有专门论坛讨论,帮你转过去