Program:
/* Connections
* Connect P2.11 to switch(development board)
* Connect P2.3 to led(development board)
* When switch is pressed led = ~led
*/
#include <lpc17xx.h>
#include "ExtInt.h"
/* LED assigned to P2.3, pin number can be changed */
#define LED 3
/* Interrupt Handler */
void EINT1_IRQHandler(void)
{
/* Toggle the LED (P2_3) */
GPIO_PinToggle(LED);
}
int main()
{
/* Initialize the external interrupt 1 */
ExtInt_Init();
/* Initalize the GPIO pin as output */
GPIO_Init(LED);
/* Enable the EINT1 interrupts */
NVIC_EnableIRQ(EINT1_IRQn);
/* Infinite loop */
while(1)
{
// Do nothing
}
}
/* Connections
* Connect P2.11 to switch(development board)
* Connect P2.3 to led(development board)
* When switch is pressed led = ~led
*/
#include <lpc17xx.h>
#include "ExtInt.h"
/* LED assigned to P2.3, pin number can be changed */
#define LED 3
/* Interrupt Handler */
void EINT1_IRQHandler(void)
{
/* Toggle the LED (P2_3) */
GPIO_PinToggle(LED);
}
int main()
{
/* Initialize the external interrupt 1 */
ExtInt_Init();
/* Initalize the GPIO pin as output */
GPIO_Init(LED);
/* Enable the EINT1 interrupts */
NVIC_EnableIRQ(EINT1_IRQn);
/* Infinite loop */
while(1)
{
// Do nothing
}
}
Hardware Connection
Connect P2.11 to switch (development board)
Connect P2.3 to led (development board)
Output
When switch is pressed led = ~led
No comments:
Post a Comment