Detailed explanation of s3c2440 external interrupt operation

Publisher:tyloo820Latest update time:2017-11-12 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

To correctly execute the external interrupt of 2440, generally two parts need to be completed: interrupt initialization and interrupt processing function.
    Before executing the interrupt, the interrupt to be used must be initialized. The external interrupt pin EINT of 2440 is multiplexed with the general IO pins F and G. To use the interrupt function, the corresponding pin must be configured to interrupt mode. For example, if we want to set port F0 to external interrupt, while the functions of other pins remain unchanged, then GPFCON=(GPFCON & ~0x3) | 0x2. After configuring the pin, you also need to configure the specific interrupt function. We need to open the mask of a certain interrupt so that we can respond to the interrupt. The corresponding register is INTMSK; we also need to set the trigger mode of the external interrupt, such as low level, high level, rising edge, falling edge, etc. The corresponding register is EXTINTn. In addition, since EINT4 to EINT7 share an interrupt vector, EINT8 to EINT23 also share an interrupt vector, and INTMSK is only responsible for the mask of the total interrupt vector, to specifically open a specific interrupt mask, you also need to set EINTMASK. The above is the most basic initialization. Of course, there are some other configurations, such as when fast interrupts are needed, INTMOD should be used, and when interrupt priority needs to be configured, PRIORITY should be used. The
    interrupt handling function is responsible for executing specific interrupt instructions. In addition, the corresponding bits in SRCPND and INTPND need to be cleared (cleared by setting 1), because when an interrupt occurs, 2440 will automatically set the corresponding positions in these two registers to 1 to indicate that an interrupt has occurred. If they are not cleared in the interrupt handling function, the system will always execute the interrupt function. In addition, as mentioned earlier, some interrupts share an interrupt vector, and an interrupt vector can only have one interrupt execution function. Therefore, EINTPEND is needed to determine which external interrupt it is, and the corresponding bits need to be cleared by setting 1. Generally speaking, the keyword __irq is used to define the interrupt handling function, so that the system will automatically save some necessary variables for us and can return correctly after the interrupt handling function is executed. It should also be noted that the interrupt handling function cannot have a return value or pass any parameters.
    In order to match this interrupt handling function with the interrupt vector table defined in the 2440 startup file, it is necessary to define the interrupt entry address variable first. The interrupt entry address must be consistent with the address in the interrupt vector table, and then pass the first address of the interrupt handling function to the variable, that is, the interrupt entry address.
    The following is an example of an external interrupt. There are four buttons on the development board, connected to EINT0, EINT1, EINT2 and EINT4 respectively. We let these four buttons control the four LEDs connected to the B5~B8 pins respectively: press the button once to turn on the LED, press it again to turn it off:

#define _ISR_STARTADDRESS 0x33ffff00

#define U32 unsigned int

#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))
#define pISR_EINT1 (*(unsigned *)(_ISR_STARTADDRESS+0x24))
#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))
#define pISR_EINT4_7 (*(unsigned *)(_ISR_STARTADDRESS+0x30))

#define rSRCPND (*(volatile unsigned *)0x4a000000) //Interrupt request status
#define rINTMSK (*(volatile unsigned *)0x4a000008) //Interrupt mask control
#define rINTPND (*(volatile unsigned *)0x4a000010) //Interrupt request status

#define rGPBCON (*(volatile unsigned *)0x56000010) //Port B control
#define r GPBDAT (*(volatile unsigned *)0x56000014) //Port B data
#define rGPBUP (*(volatile unsigned *)0x56000018) //Pull-up control B

#define rGPFCON (*(volatile unsigned *)0x56000050) //Port F control

#define rEXTINT0 (*(volatile unsigned *)0x56000 088) //External interrupt control register 0
#define rEINTMASK (*(volatile unsigned *)0x560000a4) //External interrupt mask
#define rEINTPEND (*(volatile unsigned *)0x560000a8) //External interrupt pending

static void __irq Key1_ISR(void) //EINT1
{
       int led;
       rSRCPND = rSRCPND | (0x1<<1);
       rINTPND = rINT PND | (0x1<<1);
       led = rGPBDAT & (0x1<<5);
       if (led ==0)
              rGPBDAT = rGPBDAT | (0x1<<5);
       else
              rGPBDAT = rGPBDAT & ~(0x1<<5);
}

static void __irq Key2_ISR(void) //EINT4
{
       int led;
       rSRCPND = rSRCPND | (0x1<<4);
       rINTPND = rINTPND | (0x1<<4);
       if(rEINTPEND&(1<<4))
       {
              rEINTPEND = rEINTPEND | (0x1<<4);
              led = rGPBDAT & (0x1<<6);
              if (led ==0 )
                     rGPBDAT = rGPBDAT | (0x1<<6);
              else
                     rGPBDAT = rGPBDAT & ~(0x1<<6);
       }
}

static void __irq Key3_ISR(void) //EINT2
{
       int led;
       rSRCPND = rSRCPND | (0x1<<2 );
       rINTPND = rINTPND | (0x1<<2);
       led = rGPBDAT & (0x1<<7);
       if (led ==0)
              rGPBDAT = rGPBDAT | (0x1<<7);
       else
              rGPBDAT = rGPBDAT & ~(0x1 <<7);
}

void __irq Key4_ISR(void) //EINT0
{
       int led;
       rSRCPND = rSRCPND | 0x1;
       rINTPND = rINTPND | 0x1;
       led = rGPBDAT & (0x1<<8);
       if (led ==0)
              rGPBDAT = rGPBDAT | (0x1<<8 );
       else
              rGPBDAT = rGPBDAT & ~(0x1<<8);
}

void Main(void)
{
       int light;

       rGPBCON = 0x015550;
       rGPBUP = 0x7ff;
       rGPFCON = 0xaaaa;

       rSRCPND = 0x17;
       rINTMSK = ~0x17;
       rINTPND =0x17;
       rEINTPEND = (1<<4);
       rEINTMASK = ~(1<<4);
       rEXTINT0 = 0x20222;

       light = 0x0;
       rGPBDAT = ~light;

       pISR_EINT0 = (U32)Key4_ISR;
       pISR_EINT1 = (U32)Key1_ISR; pISR_EINT2
       = (U32)Key3_ISR;
       pISR_EINT4_7 = (U32)Key2_ISR;

       while(1)
              ;     
}

Keywords:S3C2440 Reference address:Detailed explanation of s3c2440 external interrupt operation

Previous article:Detailed explanation of LCD application of s3c2440
Next article:ARM interrupt function definition

Recommended ReadingLatest update time:2024-11-16 16:32

Build jz2440v3 (arm s3c2440) development and gdb debugging environment under win10
I originally planned to develop it entirely under Ubuntu, but my level was limited and I couldn't find a suitable tool to read large codes under Ubuntu, so I had to build a development environment on Windows. 1. Main contents: 1. Build arm (s3c2440) development environment under windows10 Use vmware workstation12 pr
[Microcontroller]
Boa Web server transplanted on S3C2440 development board
The transplantation of the boa server has been completed on the PC. For "Transplantation of Boa Web Server on PC", see http://www.linuxidc.com/Linux/2011-10/44729.htm. The following will introduce how to complete the corresponding work on the S3C2440 hardware platform. The two are similar, with slight differences in
[Microcontroller]
02 Linux entry command
1 Shell Interpreter The shell interpreter receives the input characters and displays them immediately. After you press Enter, it searches for the command based on the string. Where to search? It searches in the path specified by the environment variable. # Display environment variables echo $PATH # The results are a
[Microcontroller]
02 Linux entry command
S3C2440 transplantation uboot support burning yaffs image and making patches
In the previous section, S3C2440 transplantation of uboot: trimming and modifying default parameters trimmed uboot and modified the default parameters. This section starts to make yaffs image and patch file Table of contents Flash the file system Analyze the source code Burning Yaffs test Using part to make a patc
[Microcontroller]
S3C2440 transplantation uboot support burning yaffs image and making patches
s3c2440 learning path-002 C language lights up LED
Hardware platform: jz2440 Software platform: Ubuntu16.04 arm-linux-gcc-3.4.5 Source code location: https://github.com/lian494362816/C/tree/master/2440/003_led_c 1 Main Process Following the previous blog https://blog.csdn.net/lian494362816/article/details/84309342, the principle analysis is skipped and the process i
[Microcontroller]
s3c2440 learning path-002 C language lights up LED
Design of Remote Image Wireless Monitoring System Based on S3C2440 Processor
For image monitoring systems, users often put forward such functional requirements: they hope to be able to monitor objects that are far away. These objects may be distributed in suburbs, deep mountains, wastelands or other unattended places; in addition, they hope to obtain clearer monitoring images, but the real-t
[Microcontroller]
Design of Remote Image Wireless Monitoring System Based on S3C2440 Processor
S3C2440IIC interrupt mode
#include  string.h    #include "2440addr.h"   #include "2440lib.h"   #include "Option.h"   #include "def.h"      int flag; //interrupt flag (cleared in the interrupt subroutine, i.e. flag=1 before interruption, flag=0 after interruption)      void __irq IicInt(void);    void Wr24C02(U32 slvAddr,U32
[Microcontroller]
【s3c2440】Lesson 4: External Interrupts
External interrupt initialization process The flowchart of external interrupt is as follows: The interrupt priority is not considered here, and the registers involved are as follows: External interrupt configuration 1. Initialization interrupt Set the system mode (MODE) from SVC (supervise) mode to USER mode. S
[Microcontroller]
【s3c2440】Lesson 4: External Interrupts
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号