AnsweredAssumed Answered

MSCAN Init S12G96

Question asked by Mr. Kress on Feb 13, 2012
Latest reply on Feb 14, 2012 by Mr. Kress

Hi @ all,

 

We're facing a problem with the initialisation of MSCAN Module on Microcontroller S12G96:

 

We used following code to enable MSCAN and to change settings:

void CAN_SETTINGS(void)  {        CANCTL0  = 0x01;        //CANCTL0 = 0000 0001 CAN Control Register 0 (Manual S.224, 225, 267) Einschalten des Sleepmodes                                while ((CANCTL1 & 0x01) != 0x01)   //Warten, bis Init Acknowledge Bit gesetzt ist    {    }                                          CANBTR0 = 0x93;       //CANBTR0 = 1000 1001         MSCAN Bus timing Register 0 (Manual S. 227, 228) Einstellung des Baudratenprescaler (auf Wert 10 = 9+1) und der Synchronisation Jump width (auf Wert 3 = 2+1), +1 ist immer gesetzt!!                             CANBTR1 = 0x3A;       //CANBTR1 = 0011 1010         MSCAN Bus timing Register 1 (Manual S. 228) Einstellung der Samplingrate (auf Wert 1), Time Segment 2 (auf Wert 4 = 3+1) und Time Segment (auf Wert 11 = 10+1, inclusive Propagation Time Segment), +1 ist immer gesetzt!!                   CANCTL1 = 0x80;      //CANCTL1 = 1000 00xx          CAN Control Register 1 (Manual S. 226, 227) Einschalten des MSCAN-Moduls Control Registers                                  CANIDAC = 0x10;       //CANIDAC = 0001 0000 MSCAN Identifier Acceptance Register (Manual S. 236, 237) Einstellung auf 4 16-Bit Acceptance Filter                                  //Filter 1: Filtert einen Bereich von Identifieren 0x400 bis 0x430        CANIDMR0 = 0x07;      //CANIDMR0 = 0000 0000         MSCAN Identifier Mask Register 0 (Manual S. 240)                              CANIDMR1 = 0xFF;      //CANIDMR1 = 0000 0000         MSCAN Identifier Mask Register 1 (Manual S. 240)                                                        CANIDAR0 = 0x84;      //CANIDAR0 = 0000 0000         MSCAN Identifier Acceptance Register 0 (Manual S. 239)                              CANIDAR1 = 0x00;      //CANIDAR1 = 0000 0000         MSCAN Identifier Acceptance Register 1 (Manual S. 239)                                CANIDMR5 = 0x07;      //CANIDAR5 = 0000 0000         MSCAN Identifier Mask Register 5 (Manual S. 240)                                                        CANIDMR7 = 0x07;      //CANIDMR7 = 0000 0000         MSCAN Identifier Mask Register 7 (Manual S. 240)                              CANCTL0 = 0x00;         //CANCTL0 = 0000 0001 CAN Control Register 0 (Manual S.224, 225, 267) Einstellung des Initialisierungsmodes                                   while ((CANCTL1 & 0x01) == 0x01)   //Warten, bis Initial Mode Acknowledge Bit zurückgesetzt ist    {    }            CANRIER = 0x01;        while ((CANCTL0 & 0x10) != 0x10)   //Warten, bis CAN-Bus synchronisiert ist.     {    }  }

 

 

Our problem is, that the initailisation sequence is running until:

 

    while ((CANCTL1 & 0x01) == 0x01)   //Warten, bis Initial Mode Acknowledge Bit zurückgesetzt ist    {    }

The Ínitial mode acknowledge bis will not be set to 0x00 and the programm stays here and doesn't go on anymore.

We tried to set MSCAN to sleep mode also, but it doesn't make any difference.

 

Has anybody an idea what we made wrong?

 

 

Thank you for your kind support.

 

 

Best regards

Michael

Outcomes