AnsweredAssumed Answered

FlexCAN disable Remote Frames

Question asked by eschick on Apr 24, 2017
Latest reply on Apr 26, 2017 by eschick

Hi all,

I have an issue within my FlexCAN configuration. The controller seems to send a remote Frame with the CAN-ID 0x2A7 and I can't figure out which configuration cause this sending. Within all used Tx and Rx Buffers the RTR Bit is set to 0.

Here is my whole configuration and also all used functions.

 

#define ID_Table0_CAN0 (*(vuint32_t* )(0xfffc00e0))
#define ID_Table1_CAN0 (*(vuint32_t* )(0xfffc00e4))
#define ID_Table2_CAN0 (*(vuint32_t* )(0xfffc00e8))
#define ID_Table3_CAN0 (*(vuint32_t* )(0xfffc00eC))
#define ID_Table4_CAN0 (*(vuint32_t* )(0xfffc00f0))
#define ID_Table5_CAN0 (*(vuint32_t* )(0xfffc00f4))
#define ID_Table6_CAN0 (*(vuint32_t* )(0xfffc00f8))
#define ID_Table7_CAN0 (*(vuint32_t* )(0xfffc00fc))

void canInit() {

    uint8_t   i;
    initPCR();    //init pads

    CAN_0.MCR.R = (0 | CAN_MCR_FRZ | CAN_MCR_HALT); //enter freeze mode

    while(0==CAN_0.MCR.B.NOTRDY) {}; //wait until controller enters freeze mode

    CAN_0.MCR.R = (0
            | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
            //| CAN_MCR_FEN  /* enabled RXFIFO mode */
            //| CAN_MCR_IDAM_00 /* ID format A, One full ID (standard or extended) per filter element */
            | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */
            | CAN_MCR_SRXDIS /* self reception disabled */
            //| CAN_MCR_BCC  /* individual Rx masking and queue */
            | CAN_MCR_AEN  /* Safe Tx abort enable */
            | 0x0000003F); /* enable 64 MBs */

    //TODO: Check clock configuration
//    CAN_0.CR.R = 0x04DB0006;        /* Configure for 8MHz OSC, 100KHz bit time */

//    CAN_0.CR.R = 0x07DB0000;
    CAN_0.CR.R = 0x013A0003;        // 500Kbit/s

    for (i=8; i<64; i++)
      {
        CAN_0.BUF[i].CS.B.CODE = 0;   /* Inactivate all message buffers */
      }
    ID_Table0_CAN0 = (0x12340000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table1_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table2_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table3_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table4_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table5_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table6_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    ID_Table7_CAN0 = (0x00000000<<1)|(0x40000000); /* ID(0x00000000)<<1 + EXT */
    CAN_0.BUF[9].CS.B.CODE = 8;
    //init buf05 interrupt
    canInitInterrupt();

    /* Finally clear the HALT flag in MCR to enable the FlexCAN
     * to synchronize with the CAN bus and allow
     * participation in communication. */
    CAN_0.MCR.B.HALT = 0;

    /* wait until FlexCAN ready */
    while(1 == CAN_0.MCR.B.NOTRDY) {};

    //Set transceiver in normal mode
    SET_CAN1_EN;
    SET_CAN1_STB;
}

void TransmitMsg(uint32 id, uint32 data[2]) {
  CAN_0.BUF[9].CS.B.IDE = 1;           /* 0: Use std. ID length ; 1: Use ext. ID length*/
  CAN_0.BUF[9].ID.R = id;                 /* Ext.ID = 0x12340000 */
  CAN_0.BUF[9].CS.B.RTR = 0;           /* Data frame, not remote Tx request frame */
  CAN_0.BUF[9].CS.B.LENGTH = 4;
  CAN_0.BUF[9].DATA.W[0] = data[0];
  CAN_0.BUF[9].DATA.W[1] = data[1];
  CAN_0.BUF[9].CS.B.SRR = 1;           /* Tx frame (not req'd for standard frame)*/
  CAN_0.BUF[9].CS.B.CODE =0xC;         /* Activate msg. buf. to transmit data frame */

  while ( CAN_0.IFRL.B.BUF09I == 0) { } // wait until the tx is completed.
  CAN_0.IFRL.R = 0x00000200;
}

void canIsr() {
    if(CAN_0.IFRL.B.BUF05I == 1) {
        SIU.GPDO[37].B.PDO = 1;
    }
}

void canInitInterrupt() {
    CAN_0.BUF[5].CS.B.IDE = 1;      /* MB 5 will look for a extended ID */
    CAN_0.BUF[5].ID.R = 0x12340000; /* MB 5 will look for ID = 0x12340000 */
    CAN_0.BUF[5].CS.B.CODE = 4;     /* MB 5 set to RX EMPTY */
    CAN_0.BUF[5].CS.B.RTR = 0;
    CAN_0.RXIMR[5].R = 0;

    CAN_0.RXGMASK.R = 0xFFFFFFFF;  
    CAN_0.RX14MASK.R = 0xFFFFFFFF;   /* acceptance mask,applied to IDtable[6], MB14 */
    CAN_0.RX15MASK.R = 0xFFFFFFFF;   /* acceptance mask,applied to IDtable[7], MB15 */

    CAN_0.IMRL.R = 0x00000020;    // enable BUF05I interrupt

    INTC.PSR[69].B.PRI = 10;    // set interrupt priority

}

After initialization the controller receives a frame on the FlexRay channel and sends a CAN Frame with CAN ID 0x12340000 within the FlexRay ISR.

 

Thanks in advance,

Efim

Outcomes