LPC2478 external interrupt usage

Publisher:blazingsLatest update time:2017-01-13 Source: eefocusKeywords:LPC2478 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LPC2478 external interrupt

The external interrupt model of 2478 is as follows


That is to say, port 0 and 2 support external interrupts, EINT0-2 are interrupts for three independent pins, and EINT3 is the vector shared by all interrupts of port 0 and 2.

For port 0 and 2, you do not need to configure the pins to interrupt mode. Just configure them to input mode and enable interrupts. For independent interrupts, the configuration process is as follows

1. Configure the corresponding pin to EINT mode



2. Set the mode to pull up or down according to your needs

3. Configure the interrupt mode and interrupt polarity in the system control register



4. Configure the middle end, match the interrupt function, priority, enable interrupt, etc.

 

The interrupts of PORT0 and PORT2 are actually similar in usage, mainly the configuration of EINT3

1. Select GPIO for IO port function

2. Enable the GPIO interrupt of the pin


3. Next, configure the eint3 interrupt and you can use it

 

When interrupt processing, eint0-2 can be processed directly, and port0 and port2 interrupts in eint3 need to be judged once, relying on the following three registers






From these three registers, you can see the interrupt status of each pin and choose the correct processing method

Check the code for details

 

  1. #ifndef __EXTI_H_  

  2. #define __EXTI_H_  

  3. #include "common.h"  

  4. #include "lpc24xx.h"  

  5.   

  6. extern u8 eint0Count;  

  7.   

  8. extern u8 eint3Count;  

  9.   

  10. void ExtiInit(void);  

  11.   

  12.   

  13. void GPIOEINT3Init(void);  

  14.   

  15.   

  16. #endif  



 

  1. #include "exti.h"  

  2.   

  3. u8 eint0Count = 0;  

  4. u8 eint3Count = 0;  

  5.   

  6. void __irq EINT0_Handler(void)  

  7. {  

  8.     IENABLE; /* handles nested interrupt */    

  9.     EXTINT |= (1<<0); // Clear interrupt  

  10.     //do something here  

  11.       

  12.     eint0Count = 1;  

  13.       

  14.     IDISABLE;  

  15.     VICVectAddr = 0; /* Acknowledge Interrupt */  

  16. }  

  17.   

  18. void __irq EINT3_Handler(void)  

  19. {  

  20.     IENABLE; /* handles nested interrupt */    

  21.     //do something here  

  22.       

  23.     if((IO_INT_STAT&(1<<0)) == 1)//port0 interrupt  

  24.     {  

  25.         if((IO0_INT_STAT_F&(1<<10)) != 0)//Confirm that an interrupt occurs on P0.10  

  26.         {  

  27.             eint3Count = 1;  

  28.             IO0_INT_CLR |= (1<<10);  

  29.         }  

  30.     }  

  31.     EXTINT |= (1<<3); // Clear interrupt  

  32.       

  33.     IDISABLE;  

  34.     VICVectAddr = 0; /* Acknowledge Interrupt */  

  35. }  

  36.   

  37.   

  38.   

  39.   

  40. //Use exti0 as an example  

  41. void ExtiInit(void)  

  42. {  

  43.     PINSEL4 &= ~(3<<20); //Configure as interrupt  

  44.     PINSEL4 |= (1<<20);  

  45.       

  46.     PINMODE4 &= ~(3<<20); //Configure pull-up resistor  

  47.       

  48.     EXTMODE |= (1<<0); //Edge trigger  

  49. //    

  50.     EXTPOLAR |= (1<<0); // rising edge trigger  

  51.       

  52.     //Interrupt vector configuration  

  53.     VICSoftIntClr |= (1<<14); // Clear software interrupt, eint0 interrupt source is 14 0 start  

  54.     VICIntEnClr |= (1<<14); //Disable interrupt  

  55.     VICIntSelect &= (1<<14); //Select IRQ interrupt  

  56.     VICVectAddr14 = (unsigned)EINT0_Handler; //Connect interrupt vector  

  57.     VICVectPriority14 = 0x01; //Interrupt priority register  

  58.     VICIntEnable |= (1<<14); //Interrupt vector enable is valid  

  59. }  

  60.   

  61.   

  62.   

  63. //Use p0.10 as an example  

  64. void GPIOEINT3Init(void)  

  65. {  

  66.     PINSEL0 &= ~(3<<20); //Select normal IO function  

  67.     PINMODE0 &= ~(3<<20); //Select pull-up  

  68.     IO0_INT_EN_F |= (1<<10); // falling edge interrupt enable  

  69.       

  70.       

  71.     EXTMODE |= (1<<3); //Edge trigger  

  72.     EXTPOLAR &= ~(1<<3); //Falling edge trigger  

  73.       

  74.     //Interrupt vector configuration  

  75.     VICSoftIntClr |= (1<<17); // Clear software interrupt, eint3 interrupt source is 17 0 start  

  76.     VICIntEnClr |= (1<<17); //Disable interrupt  

  77.     VICIntSelect &= (1<<17); //Select IRQ interrupt  

  78.     VICVectAddr17 = (unsigned)EINT3_Handler; //Connect interrupt vector  

  79.     VICVectPriority17 = 0x01; //Interrupt priority register  

  80.     VICIntEnable |= (1<<17); //Interrupt vector enable is valid  

  81.       

  82. }  


 

In the external interrupt handler, remember to clear the corresponding IO port interrupt first



Then clear the EINT0 interrupt. Do not clear EINT first and then clear the IO port interrupt (this will cause repeated interrupts)


Keywords:LPC2478 Reference address:LPC2478 external interrupt usage

Previous article:SPI usage of LPC2478
Next article:Detailed explanation of GPIO usage of LPC2478

Recommended ReadingLatest update time:2024-11-16 12:46

Detailed explanation of GPIO usage of LPC2478
GPIO Usage The GPIO of LPC2478 cannot disconnect the clock, it is connected when powered on. The main steps for processing GPIO are as follows 1. Set to normal IO mode 2. Set the input and output direction 3. Set the value The following registers Used to select whether the pin is a basic input or output or an alte
[Microcontroller]
Detailed explanation of GPIO usage of LPC2478
Quickly learn Arm (3)--LPC2478 memory structure
When learning Arm, it is helpful to understand the memory address allocation method for understanding various problems. SmartArm2400 uses the LPC2478 Arm chip. So by consulting the datasheet of the LPC2478 chip, you can understand the memory allocation of 2478. I learned about the memory distribution of LPC2478 from t
[Microcontroller]
Quickly learn Arm (3)--LPC2478 memory structure
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号