9S12XE CAN initialization

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

9S12XE CAN initialization

1,079 次查看
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?

标签 (1)
0 项奖励
回复
2 回复数

518 次查看
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 项奖励
回复

518 次查看
rlw
Contributor I

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

 

0 项奖励
回复