We are using S12ZVMx12EVB evaluation board(serial no AX153811742) populated with S912ZVML12.
We are trying to use CAN option and we have made the following changes to work for CAN.
- Resistors: removed R44, R43 0 ohm resistors and connected them to R35 and R34.
2. Jumpers: Closed J3 and Opened J2
We have configured PS0 as input and PS1 as output in the software.
When we are executing code we are observing that SYNCH bit in CAN0CTL0 is always set to zero and CAN communication is not working.
On the evaluation board CAN transeiver used is TJA1042T/3.
We have checked the hardware connectivity till CAN transeiver and it OK.
Please do the needful to resolve this issue.
void CAN_init(void)
{
rx_callback = NULL;
//initialise MSCAN
CAN0CTL0 = 0x01;
while (!(CAN0CTL1_INITAK)){}
CAN0CTL1_CANE = 1; /* Enable MSCAN module */
CAN0CTL1_CLKSRC = 0; /* Clock source is OSCCLK = 4 MHz */
CAN0CTL1_LOOPB = 0; /* Set to 1 for LoopBack Mode, 0 otherwise */
CAN0CTL1_LISTEN = 0; /* Not listen only mode */
CAN0CTL0_WUPE = 1; /* Enable WAKEUP */
//Baud rate = CANCLK/(Pre-scaler * time quanta)
CAN0BTR1_TSEG_10 = VALUE_TSEG10;
CAN0BTR1_TSEG_20 = VALUE_TSEG20;
CAN0BTR0_BRP = VALUE_PRESCA;
CAN0BTR0_SJW = 0x03;
CAN0BTR1_SAMP = 0;
//accept all messages
CAN0IDAC_IDAM = 0; /* Two 32 bit filters */
CAN0IDMR0 = 0xFF; /* Accept all incoming ID's */
CAN0IDMR1 = 0xFF;
CAN0IDMR2 = 0xFF;
CAN0IDMR3 = 0xFF;
CAN0IDMR4 = 0xFF;
CAN0IDMR5 = 0xFF;
CAN0IDMR6 = 0xFF;
CAN0IDMR7 = 0xFF;
//exit initialisation mode
CAN0CTL0_INITRQ = 0;
while (CAN0CTL1_INITAK){};
while(!(CAN0CTL0_SYNCH)){};
//clear flags
CAN0RFLG_RXF = 1;
CAN0RIER_RXFIE = 1;
//enable physical layer if available
#ifdef CP0CR
CP0CR_CPE = 1;
CP0CR_SPE = 1;
#endif
//enable RX interrupt
CAN0RIER_RXFIE = 1;
}