AnsweredAssumed Answered

MPC5748G FLEXCAN Recieving multiple IDs

Question asked by Wen Xiang Yock on Jun 21, 2017
Latest reply on Jun 22, 2017 by Petr Stancik

Hi,

 

I am trying to communicate between 2 MPC5748G-LCEVB boards, i have a question on how do i enable the message buffer to receive two different sets of different ID. For example, i would like to receive 0x555 and 0x666 as my ID. I studied the example on the MPC5748G Qorivva recipe FLEXCAN chapter and have some questions:

 

1) For the first initialize function, if i were to initialize for recieving 2 different ID, i will have to use 2 different MB, is that right?

   - IN this case CAN_1.MB[4] and for the second, i could use CAN1.MB[3] ?

2) Do i need to change the CAN_1.RXMGMASK.R value. I understand that this is a global acceptance mask, but does this impact the choice of acceptance of the IDs?

3) Do i need to change CAN_1.IFLAG1.B.BUF4TO1I != 4 for the MB[3]?

3) For the receive function, similarly, do i need to use a separate set of MB to pass the data, ID, length and Code out?

4) Is there anything else i need to set in order for me to receive the particular IDs, example the filtering portion of the message buffer? Do you have a simple example project for receiving multiple IDs? Could you please provide me a simple example?

 

Thank you.

WX

 

 

void initCAN_1(void) {

 

uint8_t i;

 

CAN_1.MCR.B.MDIS = 1; 

CAN_1.CTRL1.B.CLKSRC=0; 

CAN_1.MCR.B.MDIS = 0;

 

while (!CAN_1.MCR.B.FRZACK) {}

CAN_1.CTRL1.R = 0x04DB0086;

 

for (i=0; i<96; i++)

{

   CAN_1.MB[i].CS.B.CODE = 0; 

}

CAN_1.MB[4].CS.B.IDE = 0; /* 

CAN_1.MB[4].ID.B.ID_STD = 0x555;                       ///<--------------Need to change the IDs and message buffer#  ///

CAN_1.MB[4].CS.B.CODE = 4; 

CAN_1.RXMGMASK.R = 0x1FFFFFFF; 

...

...

...

...

}

 

void ReceiveMsg(void) {

   uint8_t j;

   uint32_t dummy;

 

   while (CAN_1.IFLAG1.B.BUF4TO1I != 8) {};    ////<-----------------Do i need to change this to 4? ////

   RxCODE = CAN_1.MB[4].CS.B.CODE; /* Read CODE, ID, LENGTH, DATA, TIMESTAMP*/

   RxID = CAN_1.MB[4].ID.B.ID_STD;

   RxLENGTH = CAN_1.MB[4].CS.B.DLC;

 

  for (j=0; j<RxLENGTH; j++) {

  RxDATA[j] = CAN_1.MB[4].DATA.B[j];

  }

 

RxTIMESTAMP = CAN_1.MB[4].CS.B.TIMESTAMP;

dummy = CAN_1.TIMER.R;

CAN_1.IFLAG1.R = 0x00000010;

 

}

Outcomes