MSCAN intrerupt service routine

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

MSCAN intrerupt service routine

794 Views
Kaos
Contributor I

Hi guys,

First I want to say that i am not new to uC, but new to freescale uC, at school I got a project to set up the MSCAN for the mc9s12dp256, with help from other forums and the datasheet I managed to make something, but I do not know hot to set up the MSCAN to recevie via intrerupt the CAN messages, I got it in loop back test set up, but there is nothing coming in the rx buffer. My linker gives me an error every time i try to run, Fixup Overflow in Vector 38. Can somebody give me an idea on what to do?

Labels (1)
0 Kudos
6 Replies

483 Views
kef
Specialist I

You need to add following lines to your code, so that all your ISR routines, not only MSCAN stay between them:

 

#pragma CODE_SEG __NEAR_SEG NON_BANKED

 .. your MSCAN ISR comes here

#pragma CODE_SEG

 

Linker is not happy becaus you are using banked or large memory models, in which all routines by default are allocated in banked memory and function pointers are 24-bit wide, while vector table entries are 16-bit wide, so you see fixup overflow.

0 Kudos

483 Views
Kaos
Contributor I

Hi kef,

I found that out just a few minutes ago:

#pragma CODE_SEG __NEAR_SEG NON_BANKED
#pragma TRAP_PROC
interrupt void CAN0RxISR(void)
{
unsigned char length, index;

length = (CAN0RXDLR & 0x0F);
for (index=0; index<length; index++)
{
RxData[index] = *(&CAN0RXDSR0 + index); /* Get received data */
}
CAN0RFLG = 0x01; /* Clear RXF */
}
#pragma CODE_SEG DEFAULT

 

But the problem now is that the ISR wont fire, and it set the according bits in the register, and it is in loop back, shouldn't it be receiving the same data i'm sending?

0 Kudos

483 Views
Lundin
Senior Contributor IV

As a sidenote, you don't need to use both #pragma TRAP_PROC and the non-standard interrupt keyword, they are equivalent features. Here is a link describing how to implement a vectorable in CW for HCS12 without any non-standard crap:

 

https://community.freescale.com/message/59586#59586

0 Kudos

483 Views
kef
Specialist I

Maybe your messages are filtered out by acceptance filters ?

0 Kudos

483 Views
Kaos
Contributor I

I've checked the filters, but i don't know how to debug them in simulation, i've changed the Tx and Rx ids to see what happens. but on a other note, the debugger now will let me put breakpoints inside the ISR, that meens that code will be executed, but i don't know how to force the uC to fire the ISR.

0 Kudos

483 Views
kef
Specialist I

I doubt simulator has full support for MSCAN. Check release notes. I believe simulator just accepts writes to MSCAN registerss, but nothing close to real behaviour of hardware. You need real MCU to try it.

 

0 Kudos