Interrupts On Explore M3
In this tutorial we will discuss how to use the external interrupts on Explore M3.
Contents
[hide]Prerequisites
Please check this tutorial for detailed explanation on inbuilt Lpc1768 External Interrupts.
If you are doing it for the first time, then check the below links to setup the project for generating the .bin file.
EINTx Pins
LPC1768 has four external interrupts EINT0-EINT3.
Below table shows mapping of EINTx pins.
Interrupt | LPC1768 Pin | Explore M3 pin | Enum to be used |
---|---|---|---|
EINT0 | P2.10 | ISP | EINT0 |
EINT1 | P2.11 | USB_BOOT | EINT1 |
EINT2 | P2_12 | 30 | EINT2 |
EINT3 | P2.13 | 31 | EINT3 |
Note:
- ISP Pin is used for ISP programming and it should not be zero during RESET, else the controller will in ISP mode.
- USB_BOOT Switch is used for Usb/Dfu bootloader and it should not be zero during RESET, else the controller will in USB/DFU boot mode.
Hardware Connection
LED is Connected to pin 13 on Explore M3 board.
Code
Below is the sample code to blink the LED's with 1ms delay using systick timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdutils.h" | |
#include "gpio.h" | |
#include "extintr.h" | |
#define LED1 13 | |
#define LED2 14 | |
void myExtIntrIsr_0(void) | |
{ | |
GPIO_PinToggle(LED1); /* Toggle the LED1 (13) */ | |
} | |
void myExtIntrIsr_1(void) | |
{ | |
GPIO_PinToggle(LED2); /* Toggle the LED2 (14) */ | |
} | |
int main (void) | |
{ | |
SystemInit(); | |
GPIO_PinDirection(LED1,OUTPUT); /* Configure the pins as Output to blink the Leds*/ | |
GPIO_PinDirection(LED2,OUTPUT); | |
EINT_AttachInterrupt(EINT2,myExtIntrIsr_0,FALLING); /* myExtIntrIsr_0 will be called by EINT2_IRQHandler */ | |
EINT_AttachInterrupt(EINT3,myExtIntrIsr_1,FALLING); /* myExtIntrIsr_1 will be called by EINT3_IRQHandler */ | |
while(1) | |
{ | |
//do nothing | |
} | |
} |