AnsweredAssumed Answered

CAN TX in MPC5746C

Question asked by Kavitha Kakarla on Jun 29, 2017
Latest reply on Jun 29, 2017 by Petr Stancik

Hi

I am trying to use CAN_1 channel in MPC5746C to transmit some CAN Messages.

I have taken the example code from the S32 Design Studio (which is actually configured for CAN_0) and modified it to CAN_1 for testing. And when I try to initialize I expect CAN_1.ESR1.B.SYNCH bit should be set after the succesfull initialization. But I observe the SYNCH bit is set to value 0 after initialization which represent Bus is Synchronized.


Additional Information: Using XOSC as clock input for CAN.

 

Please help me how to make the CAN Bus synchronized to transmit my CAN Message.

 

Below is the code snippet for CAN Init:

 

void initCAN_1_tx(void) { /* General init. No MB IDs iniialized */
uint8_t i;

CAN_1.MCR.B.MDIS = 1; /* Disable module before selecting clock source*/
CAN_1.CTRL1.B.CLKSRC=0; /* Clock Source = oscillator clock (40 MHz) */
CAN_1.MCR.B.MDIS = 0; /* Enable module for config. (Sets FRZ, HALT)*/
while (!CAN_1.MCR.B.FRZACK) {}/* Wait for freeze acknowledge to set */
CAN_1.CTRL1.R = 0x04DB0086; /* CAN bus: same as for CAN_0 */
for (i=0; i<64; i++) { /* MPC574xG has 96 buffers after MPC5748G rev 0*/
CAN_1.MB[i].CS.B.CODE = 0; /* Inactivate all message buffers */
}
CAN_1.MB[0].CS.B.CODE = 8; /* Message Buffer 0 set to TX INACTIVE */

SIUL2.MSCR[42].B.SSS = 1; /* Pad PC10: Source signal is CAN0_TX */
SIUL2.MSCR[42].B.OBE = 1; /* Pad PC10: Output Buffer Enable */
SIUL2.MSCR[42].B.SRC = 3; /* Pad PC10: Maximum slew rate */
SIUL2.MSCR[43].B.IBE = 1; /* Pad PC11: Enable pad for input - CAN0_RX */
SIUL2.IMCR[189].B.SSS = 3; /* CAN1_RX: connected to pad PC11 */

CAN_1.MCR.R = 0x0000003F; /* Negate FlexCAN_0 halt state for 64 MB */
while (CAN_1.MCR.B.FRZACK & CAN_1.MCR.B.NOTRDY) {} /* Wait to clear */
/* Good practice: wait for FRZACK on freeze mode entry/exit */
}

 

Please help.

Outcomes