How to use LED pin as InterruptIn??

02 Jun 2012

I have a custom board which brings the LED1, LED2, LED3, LED4 pins out to I/O points. When I use the online compiler and try to setup an InterruptIn pinA(LED3) it causes a hard fault on the board.

How do I setup and define the LED3 pin as an input rather than an LED output? Is there a p for that pin I can use instead of LED3?

Thanks

02 Jun 2012

Hi Matt,

The LPC1768 chip has 3 i/o ports that drive the various GPIO pins, and can support interrupts on port 0 and port 2, but not port 1. The LEDs (and p19 and p20) are all on Port 1, so you can't trigger interrupts from those pins unfortunately (part of the reason we used those pins for the LEDs was they were some of the least flexible).

Someone did a nice full pinout diagram which you might find useful:

FYI, you can use both the mbed Microcontroller symbol names like p5, p6, LED1 and the chip pinout names like P0_0, P1_14 when you use the mbed libraries which can be useful when you are doing your own PCB design.

Hope that helps!

Simon