S3C2440——Keyboard interrupt service routine

Publisher:电子创新者Latest update time:2022-10-25 Source: csdnKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

S3C2440 keyboard module circuit

Insert image description here

There are a total of S1, S2, S3, and S4 buttons, which correspond to the four interrupt sources EINT19, EINT2, EINT0, and EINT11 respectively. The interrupt framework and service routine are as follows:


Interrupt response, take out the keyboard number (1-4) that triggered the interrupt and put it in R5


;FileASM_Interrupt.s

;(1)Set the interrupt vector table

Mode_USR EQU 0x50 ; IRQ interrupt is open, FIQ interrupt is closed

Mode_FIQ EQU 0xD1 ; turn off IRQ and FIQ interrupts

Mode_IRQ EQU 0xD2 ; turn off IRQ and FIQ interrupts

Mode_SVC EQU 0xD3 ; turn off IRQ and FIQ interrupts


GET 2440Reg_addr.inc

    AREA MyCode, CODE,READONLY

IMPORT initial_keyboard_INT

    ENTRY ;Set interrupt vector table

B ResetHandler ;Reset interrupt service routine

B. ; handlerUndef

B. ; SWI interrupt handler

B. ; handlerPAbort

B. ; handlerDAbort

B. ; handlerReserved

B HandlerIRQ ;HandlerIRQ

B. ; HandlerFIQ


;(2)Reset interrupt handler

ResetHandler

BL Clock_Init ; initialize watchdog, clock

;BL MemSetup ;Initialize SDRAM

  LDR      SP, =SvcStackSpace ;Set management mode stack

        MSR CPSR_c, #Mode_IRQ

        LDR SP, =IrqStackSpace ; Set IRQ interrupt mode stack

        MSR CPSR_c, #Mode_FIQ

        LDR SP, =FiqStackSpace ; Set FIQ interrupt mode stack

        MSR CPSR_c, #Mode_USR ;Enter user mode

LDR SP, =UsrStackSpace ; Set user and system mode stack

  ;BL Init_DATA ;Initialize readable and writable data

BL initial_keyboard_INT

LDR R0,=pEINT0;EINT0 address in the interrupt entry transfer table

LDR R1,=EINT0 ;R1 interrupt service routine entry address

STR R1,[R0] ;EINT0 interrupt program entry address is written into the interrupt transfer table

LDR R0,=pEINT2;EINT2 address in the interrupt entry transfer table

LDR R1,=EINT2 ;R1 interrupt service routine entry address

STR R1,[R0] ;EINT2 interrupt program entry address is written into the interrupt transfer table

LDR R0,=pEINT8_23;EINT8_23 address in the interrupt entry transfer table

LDR R1,=EINT8_23 ;R1 interrupt service routine entry address

STR R1,[R0] ;EINT8_23 interrupt program entry address is written into the interrupt transfer table

MAIN_LOOP

  NOP

B      MAIN_LOOP ; infinite loop, interrupted by IRQ; initialize readable and writable data area

Clock_Init

GET Clock_Init.s ;Initialize watchdog and clock

MemSetup

GET MemSetup.s ;Initialize SDRAM

Init_DATA

GET Init_DATA.s ; Initialize the readable and writable data area


;(3)IRQ interrupt handler

HandlerIRQ

SUB LR,LR, #4 ; Calculate return address

    STMFD SP!, {LR} ;Save breakpoint to stack in IRQ mode

LDR LR,= Int_Return ; modify LR and return to Int_Return after executing the EINT8_23 handler.

LDR R0,=INTOFFSET ; Get the number of the interrupt source

LDR R1,[R0]

LDR R2,=Int_EntryTable ;Start address of interrupt transfer table

LDR PC,[R2,R1,LSL#2] ; Check the interrupt transfer table and obtain the handler entry address of EINT8_23, which is equivalent to a subroutine call without parameters, but no breakpoints are saved.

Int_Return ; You must return here after executing the EINT8_23 handler.

LDMFD  SP!, {PC }^ ;IRQ interrupt service routine returns, ^ means copying the value of SPSR to CPSR

;EINT0 handler

EINT0

MOV R5,#3

LDR R0,=SRCPND ;Clear several pending registers

    LDR R1,[R0]

    STR R1,[R0]

LDR R0,=INTPND

    LDR R1,[R0]

    STR R1,[R0]

    MOV PC,LR ; Return to IRQ interrupt service routine from EINT0 handler

;EINT2 handler

EINT2

MOV R5,#2

LDR R0,=SRCPND ;Clear several pending registers

    LDR R1,[R0]

    STR R1,[R0]

LDR R0,=INTPND

    LDR R1,[R0]

    STR R1,[R0]

    MOV PC,LR ; Return to IRQ interrupt service routine from EINT2 handler

; (4) EINT8_23 handler

EINT8_23

LDR R0,=EINTPEND ;R0 is set to the EINTPEND register address

LDR R1,[R0] ; Read EINTPEND, 24 bits in total, the lowest 4 bits are reserved

CMP      R1,#0x080000 ; Determine whether EINT19 interrupt

LDREQ  R5,=0x1 ;R5 is the key number

CMP      R1,#0x000800 ; Determine whether EINT11 interrupt

LDREQ  R5,=0x4

LDR R0,=SRCPND ;Clear several pending registers

    LDR R1,[R0]

    STR R1,[R0]

LDR R0,=INTPND

    LDR R1,[R0]

    STR R1,[R0]

LDR R0,=EINTPEND

    LDR R1,[R0]

    STR R1,[R0]

    MOV PC,LR ; Return to IRQ interrupt service routine by EINT8_23 handler

AREA MyRWData, DATA, READWRITE ;Set RW Base=0x33ffe700

Int_EntryTable

GET Int_EntryTable.s ; Interrupt transfer table, 32 entries in total

        AREA MyZIData, DATA, READWRITE, NOINIT,ALIGN=8

;Pushdown stack, according to the alignment, the starting address of the segment is 0x33ffe800, and the space of each stack area is 1k

SPACE 0x100 * 4 ; Management mode stack is empty

SvcStackSpace SPACE 0x100 * 4 ;Interrupt mode stack space

IrqStackSpace SPACE 0x100 * 4 ; fast interrupt mode stack space

FiqStackSpace SPACE 0x100 *

UsrStackSpace

END


;File Int_EntryTable.s, defines the interrupt transfer table

;32 channels in total, corresponding to 32 inputs of the arbiter

pEINT0 DCD 0 ; stores the entry address of the EINT0-3 interrupt service routine

pEINT1 DCD 0

pEINT2 DCD 0

pEINT3 DCD 0


pEINT4_7 DCD 0 ; stores the entry address of the EINT4_7 interrupt service routine

pEINT8_23 DCD 0 ; stores the EINT8_23 interrupt service routine entry address——EINT8_23


pINT_CAM DCD 0 ; stores 26 internal interrupt service routine entry addresses

pnBATT_FLT DCD 0

pINT_TICK DCD 0

pINT_WDT_AC97 DCD 0

pINT_UART0 DCD 0

pINT_SPI1 DCD 0

pINT_RTC DCD 0

pINT_ADC DCD 0

END


#include "2440Reg_addr.h" //Special register address definition


void initial_keyboard_INT(void){

    rGPGCON=((0x10<<22)|(0x10<<6)); //Set GPIO as external interrupt pin

    rGPFCON=((0x10|(0x10<<4));//Set GPF as interrupt pin

    rGPGUP=0xffff; // No pull-up

    rGPFUP = 0xff; // No pull-up

    rEINTMASK&=((0x1<<11)|(0x1<<19));//Open EINT11, 19 interrupt

    rEXTINT0=0x0; //All are low level interrupts, no filtering is used

    rEXTINT1=0x0;

    rEXTINT2=0x0;

    rINTMSK=0xFFFFFFD5; //Open interrupt

}

Keywords:S3C2440 Reference address:S3C2440——Keyboard interrupt service routine

Previous article:S3C2440 interrupt analysis (analysis of each interrupt-related register)
Next article:S3C2440——Use URAT0 interrupt mode to send and receive strings

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

s3c2440——swi exception
When the system is reset, execution starts from address 0, and the system is in svc management mode. Generally speaking, our app application is in user mode, but user mode cannot access hardware and must be in privileged mode. So here we use the swi soft interrupt method to experiment. The swi exception will cause t
[Microcontroller]
s3c2440——swi exception
Port QtEmbedded 4.6.3 tslib1.4 to S3C2440
1. Download the source code package: Go to the QT official website to download the latest version of QT FOR EMBEDDED Download the latest version of tslib1.4   2. Configure the cross-compilation environment Download the cross-compilation tool arm-linux-gcc 4.3.2 (for the version of the cross-compilation tool, please
[Microcontroller]
Porting of LWIP-1.3.0 and DM9000 based on S3C2440 on UCOS-II-2.8.6
I usually run on Linux, and I feel a little uncomfortable jumping to UCOS for a while. First of all, the compiler, GCC is a good choice, but GDB debugging is too troublesome. ADS combined with the simulator is a very good debugging environment, so I moved the code to ADS, which is completely independent of Linux, an
[Microcontroller]
Porting of LWIP-1.3.0 and DM9000 based on S3C2440 on UCOS-II-2.8.6
Porting OpenCV2.0.0 to ARM9 (II) (JZ2440----S3c2440)
1. Cross-compile libjpeg In order to enable OpenCV to process jpeg images, we must cross-compile libjpeg in advance. The version used here is jpegsrc.v6b. Download address: https://sourceforge.net/projects/libjpeg/files/libjpeg/6b/ The installation package used here: jpegsrc.v6b.tar.gz. (1) Unzip and configure jpegs
[Microcontroller]
Porting OpenCV2.0.0 to ARM9 (II) (JZ2440----S3c2440)
S3C2440—7. Storage controller accesses peripherals
1. Concept of memory interface S3C2440 is a SOC, so it has many peripherals. The general methods of driving peripherals can be divided into: Access the corresponding registers through the CPU, and then drive the peripherals through the controller CPU directly accesses peripheral addresses and drives peripherals The
[Microcontroller]
S3C2440—7. Storage controller accesses peripherals
Detailed explanation of s3c2440 NAND and NOR boot methods
1: Allocation of address space 1: s3c2440 is 32-bit, so it can address 4GB of space. Memory (SDRAM), ports (special registers), and ROM are all mapped to the same 4G space. 2: Development boards generally use SDRAM as memory flash (nor, nand) as ROM. Among them, nand flash has no address line, and at least one page
[Microcontroller]
Detailed analysis of the framework of S3C2440 block device driver
This program’s: By analyzing the block device driver framework under the 2.6 kernel, we know how to write drivers 1. What we have learned before are character device drivers. Let's recall them first. Character device driver: When our application layer reads and writes (read()/write()) character device drivers,
[Microcontroller]
Detailed analysis of the framework of S3C2440 block device driver
Embedded Linux Development (Part 9) RAM (3) S3C2440 External SDRAM
- JZ2440  S3C2440 ARM920T -built-in Steppingstone (4K-Byte SRAM) No rom -expansion EM63A165TS-6G: 32MB/chip, SDRAM, two chips in total soc The S3C2440A is developed with ARM920T core, 0.13um CMOS standard cells and a memory complier. The ARM920T implements MMU, AMBA BUS, and Harvard cache architecture with
[Microcontroller]
Embedded Linux Development (Part 9) RAM (3) S3C2440 External SDRAM
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号