CAN bus attach interrupts

17 Nov 2010

I'm trying to attach an interrupt to the can bus.... Here is some sample code:


#include "mbed.h"
#include "CAN.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
Serial pc(USBTX, USBRX); // tx, rx

DigitalOut can_Pca82c250SlopePin(p28);

CAN can2(p30, p29);

CANMessage can_MsgRx;

void canReader(void)
    if (
        led1 = !led1;

int main()
    pc.printf("Starting CAN Monitor\r\n");

    LPC_CAN2->BTR = 0x52001C;
    pc.printf("CAN Freq = 0x%08x\r\n", LPC_CAN2->BTR);
    // activate external can transceiver
    can_Pca82c250SlopePin = 0;

    while (1)
        led2 = !led2;

Nothing happens...only the led2 flashes.  If I move the read function to the while loop and comment out the attach call, led1 flashes.

Can I get interrupts on those pins? Any suggestions? I'm using the latest mbed library  version 26 I think.

Am I missing something?


20 Dec 2010


I believe I spoke with you on or about the program you wrote for the 2007 Dodge Charger you have.  I am attempting to use the ECU CAN BUS board from SKPANG electronics to communicate with my car.  I am getting a factory remote start and want to interface with the 2009 dodge charger.  I think the first step might be to use the board as a data logger to capture CAN bus data and parse through it.  Now I see to call your plugin for riderunner allowed you to lock and unlock and pop the trunk through the CAN Bus.  How did you arrive at those values?  to me it seem to corrolate with the pressing of the remote buttons?  If that is the case it would seem that an OEM remote starter with a button on the key would follow the same path to being able to remote start the vehicle from the CAN BUS.


Any thoughts?


Sorry to high jack your thread.

08 Jan 2011

Kevin... just saw your message...

I logged all the data that came out of the serial port when monitoring the can bus.... at the time, I had it set up that a marker was inserted in the data when I pressed a button on the computer. So that way when I pressed a key, then I knew where to start looking in the data. For all of those actions, it's the same as when you press the lock/unlock/pop trunk buttons from inside the car....

I'm not sure the same mechanism would work to start the car.... but I would love to find out. I don't have the remote start capability with my car, so I can't test. If only I could get enough donations to buy a new car that has some of these cool features :)....


14 May 2013

Hi Ryan,

Did you get a solution to your problem with CAN's attach function? I am facing the exact same problem myself.

I read here: ( that there's a bug with the CAN's attach function which prevents it from working as intended to. The library version is 25.

Please let me know if you managed to use CAN's attach function through some workaround.

Thank you.

14 May 2013

Oh, there was a slight difference in the way I was using the attach function. You used .attach(&func)... I set a function pointer, (void (*fptr)); set this pointer equal to the address of the function: (fptr = &(func)); and then called attach using this pointer... .attach((*fptr))...

Just letting you know (I know there isn't really any difference). I tried your code as well and it didn't work either.