FlexCAN disable Remote Frames

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCAN disable Remote Frames

Jump to solution
1,598 Views
eschick
Contributor III

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

Labels (1)
0 Kudos
1 Solution
1,234 Views
eschick
Contributor III

Hi all,

I solved the issue. The problem was coused by a fault configuration within the "Example-TRK-MPC5604P-FlexCAN-SimpleTx-CW210" example project, which I used for my software. The example configures 64 MBs, but the controller only supports 32 MBs, so while sending my data within the MB 9 an other MB with a different ID was send simultaneously.

So the solution is just to enable 32 MBs.

CAN_0.MCR.R = (0
            | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
            | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */
            | CAN_MCR_SRXDIS /* self reception disabled */
            | CAN_MCR_AEN  /* Safe Tx abort enable */
            | 0x0000001F); /* enable 32 MBs */

for (i=0; i<31; i++)
      {
        CAN_0.BUF[i].CS.B.CODE = 0;   /* Inactivate all message buffers */
      }

Regards,

Efim

View solution in original post

0 Kudos
3 Replies
1,235 Views
eschick
Contributor III

Hi all,

I solved the issue. The problem was coused by a fault configuration within the "Example-TRK-MPC5604P-FlexCAN-SimpleTx-CW210" example project, which I used for my software. The example configures 64 MBs, but the controller only supports 32 MBs, so while sending my data within the MB 9 an other MB with a different ID was send simultaneously.

So the solution is just to enable 32 MBs.

CAN_0.MCR.R = (0
            | CAN_MCR_FRZ  /* enabled to enter Freeze mode */
            | CAN_MCR_HALT /* enter freeze mode if FRZ bit is set */
            | CAN_MCR_SRXDIS /* self reception disabled */
            | CAN_MCR_AEN  /* Safe Tx abort enable */
            | 0x0000001F); /* enable 32 MBs */

for (i=0; i<31; i++)
      {
        CAN_0.BUF[i].CS.B.CODE = 0;   /* Inactivate all message buffers */
      }

Regards,

Efim

0 Kudos
1,234 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi Efim,

Seems you do not use RX FIFO, but keep initializing of ID table and inactive just MB 8 to 64. Thus buffers MB0 to MB7 are not initialized (except of MB5) and can contain random values.

 

So remove ID table initialization and inactive all MBs using

for (i=0; i<64; i++)
{
        CAN_0.BUF[i].CS.B.CODE = 0;   /* Inactivate all message buffers */
}

 

BR, Petr

BR, Petr

0 Kudos
1,234 Views
eschick
Contributor III

Hi Petr,

thanks for your response.

I removed the ID table initialization and inactivated all message buffer during init, but still have a remote frame send by the controller. Only the ID of this frame changed from 0x2A7 to 0x27.

Regards,

Efim

0 Kudos