Ron Wilson

9S12XE CAN initialization

Discussion created by Ron Wilson on Aug 25, 2010
Latest reply on Aug 30, 2010 by Ron Wilson

We are developping an application on the 9S12XE family that uses CAN communications.


Using our own driver, CAN communications works fine, however, we have a requirement to use the driver from Vector CAN-Tech. Unfortunately, the initialization fails on the first step.


There were no changes made beyond replacing our driver with Vector's. More specifically, everything up to the call to "CanInit" is the same. Also, I have compared the 2 versions of CanInit and found that the differences are purely typographical. I made sure that all the correct registers at the correct addresses are being referenced.


Obviously, I cant show the Vector code, but the differences are typographical. Here is a clipping of the begining of our CanInit function:


void CanInit ( void)
    msCAN12.CANCTL0 = INITRQ_msk;              // Enter into Init mode and sleep mode
    while ((msCAN12.CANCTL1 & INITAK_msk) == 0) // Wait for CAN to enter Init mode
    msCAN12.CANCTL1 = CANE_msk;                // Enable the CAN module

The observed symptom is that the while loop waits on the "INITAK" flag until the COP times out.


Again, as I said, this works for our driver, but fails in Vector's driver.;


I have considered the possibility of a code position depandant\cy issue, however, using the debugger shows the register values just before writing the "INITRQ" request are the same. In particular, the clocking settings are identical and are according to the tables and formulas in the data sheet (which is expected, given that the only code changes were to replace the CAN driver).


Maybe there are things not documented in the data sheet that need to be considered regardless of which driver is being used.


Again, as I said, this works for our driver, but fails in Vector's driver.;


Any suggestions as to what else to look for?