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 (can2.read(can_MsgRx))
{
led1 = !led1;
}
}
int main()
{
pc.baud(115200);
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;
can2.attach(&canReader);
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?
Thanks!
I'm trying to attach an interrupt to the can bus.... Here is some sample code:
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?
Thanks!