You may have a bit of a problem here. Are you using the Mbed library CAN?
The reason I ask is it has a method .attach() that allows you to attach an interupt callback. However, it only calls back on receive. A bit of investigation shows that bit0 of the IER register is set when you call .attach() as you might expect. So, in theory, you could just do
LPC_CAN1->IER |= (1UL << 3);
which would also enable the interrupt you are seeking to trap and count. And here's the problem. According to the manual the CR register bits 0 through 10 are reset when the register is read. So, if the Mbed library reads this register before making the callback to your function you will never see bit3 as set. Conversely, if it doesn't and your handler then reads the CR register to test bit3, your ISR will reset bit0 meaning the Mbed library will not see bit0 set.
So, it's down to if you are using the Mbed library or not. Seems to me if you want to extend the Mbed lib to add extra functionality then you may come stuck and have to do your own implementation.
In the MBed compiler, can you use any of the interrupts that are supported by the device? I'm having a hard time understanding how to turn on a specific interrupt and writing the ISR for that interrupt.
I'm looking for some sample code how to enable a specific interrupt and then implement the ISR for that interrupt.
In particular I want to enable the CAN Interrupt and Capture Register (CAN1ICR - 0x4004 400C, CAN2ICR - 0x4004 800C) and have the ISR increment a counter if bit 3 (Data overrun) is set at the time the interrupt occured.