LPC1768 Novice Learning GPIO and External Interrupts

Publisher:心语如画Latest update time:2018-06-27 Source: eefocusKeywords:LPC1768  GPIO Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The P0 and P2 ports of LPC1768 can be used for input and output, and can also be configured as interrupt sources.

Now P2.10 is used as a button and is configured as follows:

void BUTTON_init(void)

{

 LPC_GPIO2->FIODIR      &=~(1 << 10);    /* PORT2.10 definedas input       */

 LPC_GPIOINT->IO2IntEnF |=  (1<< 10);    /* enable falling edgeirq         */

 

 NVIC_EnableIRQ(EINT3_IRQn);             /* enable irq in nvic             */

}

void EINT3_IRQHandler()

{

 LPC_GPIOINT->IO2IntClr |= (1 << 10);     /* clear pending interrupt         */

    LED_ON;

Dealy(1000);

 LED_OFF;

}

EINT3 and GPIO interrupts are shared, so pressing a button directly enters the EINT3 interrupt service routine.

 

The lpc1768 has 4 external interrupt inputs, P2.10~P2.13, and P2.10 is also used as the button

void EINTInit( void )

{

 LPC_PINCON->PINSEL4 = 0x00100000;      /*set P2.10 as EINT0 and

                                                               P2.0~7GPIO output */

 LPC_GPIO2->FIODIR = 0x000000FF;    /*port 2, bit 0~7 only */

 LPC_GPIO2->FIOCLR = 0x000000FF;   /*turn off LEDs */

 

  LPC_SC->EXTMODE = EINT0_EDGE;             /* INT0 edge trigger */

 LPC_SC->EXTPOLAR = 0;                          /* INT0 is falling edge by default */

 

 NVIC_EnableIRQ(EINT0_IRQn);

 return( TRUE );

}

void EINT0_IRQHandler (void)

{

 LPC_SC->EXTINT = EINT0;          /* clear interrupt */   //EINT0==0x10

              LED_ON;

Dealy(1000);

 LED_OFF;

}


Keywords:LPC1768  GPIO Reference address:LPC1768 Novice Learning GPIO and External Interrupts

Previous article:LPC1768 Novice Learning Road systick
Next article:Network communication of lpc1768

Recommended ReadingLatest update time:2024-11-16 13:57

STM8S Self-study Notes-006 GPIO input: key input and key filtering
GPIO Input In "STM8S Self-study Notes-003 GPIO Output: Lighting up LEDs and Marquee Effects", we have set the GPIO of the LED to push-pull output mode, which is only one of the GPIO output functions. Similarly, GPIO has more than one input function. Floating input, no interrupt Pull-up input, no interrupt Floating i
[Microcontroller]
STM32 GPIO pin working mode and output speed summary notes
GPIO output speed There are three output speeds to choose from in the I/O port output mode (2MHz, 10MHz, 50MHz). This speed refers to the response speed of the I/O port drive circuit. There are multiple drive circuits with different responses inside the I/O pin, and users can choose the appropriate drive circuit accor
[Microcontroller]
STM32 GPIO pin working mode and output speed summary notes
Linux ARM (IMX6U) bare metal key input experiment (GPIO output and input)
The previous articles all explained how to use the GPIO output control function of I.MX6U. The IO of I.MX6U can be used not only as output but also as input. There is a button on the I.MX6U-ALPHA development board. The button is connected to an IO. Configure this IO as an input function. Read the value of this IO to g
[Microcontroller]
Linux ARM (IMX6U) bare metal key input experiment (GPIO output and input)
STM32_GPIO configuration and library function explanation - LED marquee
gpio general-purpose input/output general-purpose input/output port List of GPIO register abbreviations   Each bit of the GPIO port can be configured into multiple modes by software.           During and immediately after reset, the multiplexing function is not enabled and the I/O ports are config
[Microcontroller]
STM32_GPIO configuration and library function explanation - LED marquee
LPC1768USB endpoint response and descriptor definition
#ifndef __USBEP1_H_ #define __USBEP1_H_   #include "usb.h" #include "usbhw.h" extern s8 sendBuffer ; //Mouse data send buffer extern u8 mouse_connect; //mouse connection flag   void usb_ep1_in_process(void);   void usb_ep1_out_process(void);   #endif     #include "usbep1.h"     s8 sendBuffer = {0}; //Mouse data sendin
[Microcontroller]
There is a bug in the library function of STM32L1xx (stm32l1xx_gpio.c)
When using STM32L151, I encountered the problem that the GPIO_PinAFConfig (xx,xx,xx) function is invalid, and sometimes it causes the program HardFault. I used direct register operation to avoid this problem before, but this time HardFault occurred. I think I have to find the reason, otherwise I have to modify the reg
[Microcontroller]
LPC1768 Interrupt
1 External interrupt: There are only 4 specific external interrupt pins. 1 On a specific pin, the pin function should select the corresponding external interrupt function 2 set trigger conditions (high and low levels, rising/falling edges) 3 NVIC settings, specific channels. Two GPIO interrupts: 1 has only pins on G
[Microcontroller]
LPC1768 IAP upgrade analysis and routine sharing
1. Introduction to IAP IAP is the abbreviation of "in  applicatin  programming", which means that the MCU can get new code in the system and reprogram itself, that is, change the application. It is different from the ISP programming we are familiar with. The ISP programming interface of LPC1768 is serial port 1. If
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号