SAM7X CAN driver interrupt trouble

Hi all,

i am working on a CAN driver, i have 2 dev. boards connected via CAN.

Each 100 ms one of the boards requests data from the other board. That part runs smoothly now. The problem i have now is that, if i disconnect the 2 boards from each other, my application hangs, because of the CAN ISR is being continually run, not letting my app. get some processor time.

The problem for me is i cant see the source of the interrupt, in the ISR

i have the following:

ulIntStatus = AT91C_BASE_CAN->CAN_SR;

ulIntMask= AT91C_BASE_CAN->CAN_IMR;

ulIntStatus &= ulIntMask;

this results in ulIntStatus = 0.

i have made a crude workaround for this:

in the ISR:

if (ulIntStatus == 0)
{	 
        msgstatus= AT91C_BASE_CAN->CAN_MB0.CAN_MB_MSR;
        msgstatus= AT91C_BASE_CAN->CAN_MB1.CAN_MB_MSR;
        AT91C_BASE_CAN->CAN_MR = 0x0;	// disable CAN
}

and then in the app.:

if (!(AT91C_BASE_CAN->CAN_MR & 0x01))
{
        // Reinitialize CAN
        Communication_Init();
}

I would really like the CAN driver to be able survive the disconnection on its own, rather than having to check if the CAN controller was disabled.

any insights or solutions would be greatfully appreciated.

regards,

Martin

P.S i am using yagarto gcc 4.1.1 and eclipse

P.S.S i am using mailbox0 to send and mailbox1 to receive on both boards

Why is the CAN ISR being called? Couldn’t you just disable the CAN error ISRs?

NleahciM:
Why is the CAN ISR being called? Couldn’t you just disable the CAN error ISRs?

hi,

i dont quite get what you mean, but since i do not mask any CAN interrupts that are pending, i am at a loss as to why i end up in the the CAN ISR.

are you using the Atmel EK board or the Olimex dev board?

Hi,

i am using the Atmel EK

Barden:
Hi,

i am using the Atmel EK

can you post your initialization code? I'm specifically interested in how you are initializing the interrupts - as your problem is certainly an odd one.