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 __irq is used 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. [page]
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 is the instruction 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. [page]
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:High-speed power calculation based on CS5463 electric energy measurement circuit
Next article:Design of an electronic scale system based on a single-chip solution
Recommended ReadingLatest update time:2024-11-17 00:46
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- 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
- Arteli--5V IO withstanding voltage is weak when driving LED at high level
- MCU AD protection
- Those who have played with ARM should know what CMSIS is?
- [Mill MYB-YT507 development board trial experience] i2c driver
- STM8 Chinese Reference Manual
- [Watch the Power Supply Seminar and Win a Prize] A simple method to easily design AC-DC front-end modules
- Fixed-point programming of DSP floating-point calculation
- 【McQueen Trial】+Building Development Environment
- EEWORLD University ---- ESP8266 Development Tutorial
- GP9303 and GP8101 Circuit Review: Analog Signal Isolation