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.
Previous article:Design and implementation of fingerprint recognition system based on ARM9
Next article:Design of data collector based on STM32
- Popular Resources
- Popular amplifiers
- Chip Manufacturing: A Practical Tutorial on Semiconductor Process Technology (Sixth Edition)
- Principles and Applications of Single Chip Microcomputers and Embedded Systems
- Embedded Microsystems (Electronics and Embedded Systems Design Series)
- Software Debugging Second Edition Volume 1 Hardware Fundamentals
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
- Infineon Position2Go Development Kit Review - skypinglee
- Schematic diagram of a quadrature oscillator
- Please tell me about the PB pin of GD32E230C
- Qorvo UWB Solution Receives Apple U1 Interoperability Certification
- Can't even see the taillights? LED makes car tail lighting safer
- EEWORLD University - How and why to replace discrete MOSFETs with load switches
- 【ESP32-C3-DevKitM-1】+ESP32 series universal Windows environment construction
- Digi-Key KOL video is here~ Senior algorithm engineer talks about the secrets of image processing
- 【RPi PICO】Run Fuzix system
- 【EVAL-M3-TS6-665PN】2. PFC working principle