Interrupt processing method of touch screen in ARM system

Publisher:三青Latest update time:2014-10-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the improvement of embedded microprocessor performance, more and more peripheral interface devices are integrated, and the peripheral devices and processors mostly communicate in the form of interrupts. Even in the absence of an operating system, it is often necessary to dynamically load the interrupt processing routines of multiple peripheral devices, thereby realizing centralized dynamic management of multiple peripheral devices. At the same time, the interrupt function can solve the waiting delay problem caused by the CPU's internal running speed being much faster than the external bus speed. Therefore, in the application design of embedded microprocessors, interrupt processing is usually one of the core tasks of the system.

  
1 Touch screen

  (1) Touch screen introduction

  With the increasing number of multimedia information queries, people are paying more and more attention to touch screens. Touch screens have many advantages such as durability, fast response, space saving, and easy communication. As a new computer input device, it is currently the simplest, most convenient, and natural way of human-computer interaction. It gives multimedia a new look and is a very attractive new multimedia interactive device. The touch screen consists of a touch detection component and a touch screen controller. The touch detection component is installed in front of the display screen to detect the user's touch position and send the received information to the touch screen controller; the main function of the touch screen controller is to receive touch information from the touch point detection device, convert it into touch point coordinates and send it to the CPU, and at the same time receive commands from the CPU and execute them. According to the working principle of the touch screen and the medium for transmitting information, the touch screen can be divided into four types, namely resistive, capacitive induction, infrared, and surface acoustic wave. The four-wire resistive screen is used here.

  (2) S3C2410A touch screen controller

  The external circuit of the S3C2410A touch screen is mainly used to control the on/off status of the upper and lower conductive layers and to obtain voltage. After obtaining the voltage, the analog quantity needs to be converted into a digital quantity. This part of the work is mainly achieved by the analog-to-digital converter in the S3C2410A chip. That is, the function of the touch screen is actually divided into two parts, namely the external circuit part of the touch screen and the A/D conversion control part of the S3C2410A chip.

  
2 ARM embedded operating system interrupt processing method

  In embedded systems, the functions of external devices are mainly realized by interrupt mechanisms. Therefore, ARM, as a typical representative of embedded microprocessors, has established a complete set of exception handling mechanisms to ensure the real-time performance and stability of the system.

  2.1 S3C2410A interrupt register

  Each register plays a different role in the interrupt handling process. The interrupt process is shown in Figure 1.

 

  2.2 Interrupts and Interrupt Service Routines

  The hardware logic of the interrupt will point the detected interrupt to the address of the interrupt service routine in some way. This address appears in the header file as a macro definition. In your own program, the user assigns the address of the interrupt service routine to this pointer, thereby linking the interrupt with the interrupt service routine.

  In order to facilitate the use of high-level languages ​​to write exception handling functions, the ARM compiler has made specific extensions to the exception handling functions. As long as the keyword __irq is used, the compiled function will meet the needs of exception response for scene protection and recovery.

  In the ADS compiler, __irq is used to declare an IRQ interrupt service routine. If you use __irq to declare a function, then the function is an IRQ interrupt service routine, and the compiler will automatically add interrupt context protection code inside the function.


3. Interrupt mode to realize touch screen drive

  3.1 Setting and enabling interrupt registers

  The touch screen of S3C2410A is an internal interrupt with interrupt. When an interrupt occurs, the corresponding position of SUBSRCPND is set to 1. If it is not masked by INTSUBMSK, then the corresponding position of SRCPND is set to 1. If it is not masked by INTMSK, INTMOD is further set. Here, the IRQ interrupt mode is adopted, so SRCPND can have multiple positions set to 1 (FIQ can only have 1 bit). After PRIORITY, a high priority is selected, and then the corresponding position of INTPND is set to 1 (only 1 bit can be selected), and then enter IRQ for CPU processing.

 

  First, we must clarify the relationship between SUBSRCPND and SRCPND. Several SUBSRCPNDs may correspond to the same SRCPND. After continuous summarization, the corresponding relationship is listed in Table 1. From the table, we can see that the touch screen needs to use the INT_TC bit in SUBSRCPND, that is, SUBSRCPND[9]. Here we define the variables:

  #define BIT_SUB_TC(0x1<<9)

  The corresponding bit is the INT_ADC bit in SRCPND, that is, SRCPND[31], and the variable is defined:

  #define BIT_ADC(0xl<<31)

  INTMOD and PRIORITY use the default settings. Therefore, the touch screen interrupt process can be written as:

 

  3.2 Touch screen interrupt and touch screen interrupt program

  First, enable the interrupt vector of the ARM chip. When an IRQ interrupt comes, the CPU will automatically fetch instructions at address 0x18. The instruction at 0x18 is calculated by the CPU according to the interrupt source. Here, the touch screen interrupt INT-ADC comes, so the instruction at 0x18 is to jump to address 0x9c. Then execute the instruction "ldr pc, = HandlerINT_ADC". The result of executing this instruction is to jump to "HandlerINT_ADC" for execution.

  So what instruction is at "HandlerINT_ADC"? From the memory location of accessing the absolute address "#define pISR_ADC(*(unsigned*)(ISR_STARTADDRESS+0x9c))", we can know that the address at "HandlerINT_ADC" is _ISR_STARTADDRESS+0x9C.

        The above statement converts the unsigned integer _ISR_STARTADDRESS+0x9c into a pointer pointing to RAM, which is accessed through the statement "pISR_ADC=(int)touchscreen;". touchscreen is the defined touch screen interrupt program, and the interrupt service program must be declared using the "__irq" keyword. In this way, the user assigns the address of the interrupt service program to the pointer in his own program, thereby linking the touch screen interrupt with the touch screen interrupt program. The connection between the entire touch screen interrupt and the touch screen interrupt program is shown in Figure 2.


 

 

  
Conclusion

  This article completes the setting of the touch screen related interrupt registers, and writes the touch screen interrupt handler, and uses the method of writing the "__irq" function to realize the touch screen control based on interrupts. In practical applications, the program design is simple and reliable, the touch point coordinates are read accurately, and there is no sticking phenomenon, achieving the expected effect.

Reference address:Interrupt processing method of touch screen in ARM system

Previous article:Design and implementation of fingerprint recognition system based on ARM9
Next article:Design of data collector based on STM32

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号