9S12XE CAN initialization

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

9S12XE CAN initialization

956 Views
rlw
Contributor I

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?

Labels (1)
0 Kudos
2 Replies

395 Views
Lundin
Senior Contributor IV

I know for certain that you cannot enter MSCAN sleep mode without the CAN module enabled. I would imagine you cannot enter init mode either. Why would you want to init something that isn't there? Set CANE the first thing you do.

 

Also note that CANE is write-once, so if you are running in normal single chip mode without BDM attached, you can only write to that bit once.

 

0 Kudos

395 Views
rlw
Contributor I

Ultimately, someone at Vector talked to someone at Freescale and they were able to provide a work-around.

 

0 Kudos