void MSCAN_INITIAL(void) { CAN0CTL0_INITRQ=1; CAN1CTL0_INITRQ=1; //the MSCAN Initialization Mode while(!CAN0CTL1_INITAK); while(!CAN1CTL1_INITAK); //确认MSCAN进入了Initialization Mode
CAN0IDAC=0x10; //4*16位接收滤波模式 CAN1IDAC=0x10; CAN0IDAR0=ID0[0]; CAN1IDAR0=ID1[0]; CAN0IDAR1=ID0[1]; CAN1IDAR1=ID1[1]; CAN0IDAR2=ID0[2]; CAN1IDAR2=ID1[2]; CAN0IDAR3=ID0[3]; //MSCAN Identifier Acceptance Registers CAN1IDAR3=ID1[3]; CAN0IDAR4=0x41; CAN1IDAR4=0x41; CAN0IDAR5=0x41; CAN1IDAR5=0x41; CAN0IDAR6=0x41; CAN1IDAR6=0x41; CAN0IDAR7=0x41; CAN1IDAR7=0x41;
CAN0IDMR0=0xFF; CAN0IDMR1=0xFF; CAN0IDMR2=0xFF; CAN0IDMR3=0xFF; CAN0IDMR4=0xFF; CAN0IDMR5=0xFF; //MSCAN Identifier Mask Registers CAN0IDMR6=0xFF; CAN0IDMR7=0xFF;
CAN1IDMR0=0xFF; CAN1IDMR1=0xFF; CAN1IDMR2=0xFF; CAN1IDMR3=0xFF; CAN1IDMR4=0xFF; CAN1IDMR5=0xFF; CAN1IDMR6=0xFF; CAN1IDMR7=0xFF;
CAN0BTR0=0x63; //Synchronization jump width 2 Tq clock cycles CAN1BTR0=0x63; //Baud Rate Prescaler Bin 100001=34 Prescaler value CAN0BTR1=0x13; //SAMP=1time segment 2=2 Tq clock cycles CAN1BTR1=0x13; //time segment 1=4 Tq clock cycles CAN0CTL1_CANE=1; //CAN0 enable && Oscillator Clock. CAN1CTL1_CANE=1; //CAN1 enable CAN0CTL0_INITRQ=0; //INITRQ=0 CAN1CTL0_INITRQ=0; while(CAN0CTL1_INITAK); while(CAN1CTL1_INITAK); //确认MSCAN退出了Initialization Mode
CAN0RIER=0x01; //CAN0 Interrupt Enable CAN0CTL0_TIME = 1; CAN1CTL0_TIME = 1; }
帮我看看是不是初始化的问题??
我现在只要实现能发能收就行....CAN1发送,CAN0接收!!
[此贴子已经被作者于2006-1-10 21:19:47编辑过] |