Sorry for the late reply.
First of all, the CANE bit is one of the notorious "write-once" bits. This means that in normal single chip mode (without debugger attached), you can only write to it once, and after that the value written stays. This might cause various unintended errors.
Also, are you sure that the line setting INITAK in CANCTL0 is executed? I can't find any errors in your code, though I only looked through it briefly.
The line setting CANCTL1 looks rather fishy. I would disassemble that one and see what it actually does.
I know that the MSCAN initialization is a bit delicate: I always put the module in sleep mode before initializing it. I think this was advised in some Freescale errata to avoid problems in case the init code is called more than once in a program.
Here is how I do it:
reg_CANCTL0(port) |= SLPRQ; /* sleep mode */
reg_CANCTL0(port) |= INITRQ; /* init mode */
while((reg_CANCTL1(port) & SLPAK)==0) /* wait until CPU enters sleep mode. */
{
;
}
reg_CANCTL1(port) |= CLKSRC; /* clksrc=bus */
/* set baudrate, filters & acceptance registers etc... */
reg_CANCTL0(port) &= ~SLPRQ; /* leave sleep mode */
reg_CANCTL0(port) &= ~INITRQ; /* leave init mode */
if(useRxInterrupt) /* if the interrupts are used */
{
reg_CANRIER(port) = RXFIE;
}
while ((reg_CANCTL1(port) & (SLPAK|INITAK)) > 0) /* wait until CAN is running */
{
;
}