Ma Ming

msCAN question?

Discussion created by Ma Ming on Feb 18, 2006
Latest reply on Apr 27, 2006 by Thomas Gaffney
Hi,
Does anybody tried to work with the CAN bus on the current board of 9s12dp256?
 
I have some question on it ...
 
At first,my program works properbly in loop back mode.
However when I config it to work in nomal mode . the listening CAN node receive nothing.
Does the following Initialize have error?
:smileyhappy:
void MSCAN_INITIAL(void)
{
 CAN0CTL0_INITRQ=1;
 CAN1CTL0_INITRQ=1;         //the MSCAN Initialization Mode
 while(!CAN0CTL1_INITAK);   //The MSCAN has entered Initialization Mode.
 while(!CAN1CTL1_INITAK);   
 
 CAN0CTL1_CANE=1;    //CAN0 enable && Oscillator Clock.
 CAN1CTL1_CANE=1;    //CAN1 enable
 CAN0IDAC=0x20;               //Eight identifier acceptance filters,
 CAN1IDAC=0x20;
 
 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 100011=35 Prescaler value
 
 CAN0BTR1=0x13;    //SAMP 1 timetime segment 2=2 Tq clock cycles
 CAN1BTR1=0x13;    //                         time segment 1=4 Tq clock cycles
 
 CAN0CTL1_LISTEN=0;  //1 = Listen Only Mode activated
 CAN1CTL1_LISTEN=0;  //LISTEN bit RESET to 1
 
 //CAN1CTL1_LOOPB=1;  //1 = Loop Back Self Test enabled
 
 CAN0CTL0_INITRQ=0; //INITRQ=0
 CAN1CTL0_INITRQ=0;
 while(CAN0CTL1_INITAK);
 while(CAN1CTL1_INITAK);    //out Initialization Mode

 CAN0RIER=0x01;        //CAN0  Interrupt Enable
 CAN1RIER=0x01;        //CAN1  Interrupt Enable
}
 
:smileyvery-happy:
Here is my Transmit program.
     CAN1TBSEL=CAN1TFLG;  //Transmit Buffer Selection
     CAN1TXIDR0=ID0[0];
     CAN1TXIDR1=ID0[1]&0xE0;
     CAN1TXDSR0=0x47;
     CAN1TXDSR1=0x47;
     CAN1TXDSR2=0x46;
     CAN1TXDSR3=0x45;
     CAN1TXDSR4=0x44;//MSCAN 1 Transmit Data
     CAN1TXDSR5=0x43;
     CAN1TXDSR6=0x47;
     CAN1TXDSR7=0x48;     
     CAN1TXDLR=8;      
     CAN1TXTBPR=0x00;        
     CAN1TFLG=CAN1TBSEL;
if you find some errors,I beg you tell me .
thanks a lot for you help me:womanvery-happy:
( if you want to see the hardware of my current board ,you can visit or see the Attachment:

Outcomes