CMCR0=0才能开中断
void CAN_Init(void)
{
/* CMCR0: ??=0,??=0,??=0,SYNCH=0,TLNKEN=0,SLPAK=0,SLPRQ=0,SFTRES=1 */
CMCR0 = 1; /* CAN reset */
/* CMCR1: ??=0,??=0,??=0,??=0,??=0,LOOPB=0,WUPM=0,CLKSRC=0 */
CMCR1 = 0; //2Mhz
CIDAC_IDAM = 0;
CIDAR = 0x00000000; //Set the acceptance code
CIDMR = 0xFFFFFFFF; //Set the acceptance mask
CBTR0 = 0x43;
CBTR1 = 0xA3; //波特率62.5K
CMCR0 = 0x00; //CAN模块设置为数据输入输出状态
CRIER = 0x01; //CAN接收中断使能
} |