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;
}
Previous article:LPC1768 Novice Learning Road systick
Next article:Network communication of lpc1768
Recommended ReadingLatest update time:2024-11-16 13:57
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Add uart6 driver
- How fast can electric vehicles be “fast charged”?
- 5G millimeter wave RF algorithm technology
- Share NFC universal card reader circuit diagram
- SAM-L10-L11 series Questions and Answers
- LC filter design issues in DCDC step-down circuits
- EEWORLD University Hall----RMB settlement, VAT invoice issuance and various payment methods
- [CB5654 Intelligent Voice Development Board Review] Comparison of Voice Recognition Development Boards
- C2000 Delfino MCU F28379D LaunchPad Development Kit
- [HPM-DIY] HPM SDK updated to 0.13 SD card reading and writing performance greatly improved