From the previous section, we know that the detection of touch screen presses and the calculation of touch point coordinates are accomplished through the five switches S1 to S5. By controlling the opening and closing of the five switches at different times, the XY coordinates of the touch point can be obtained.
Check the 2440 chip manual to see how the touch screen works.
First, we can choose which channel to control through the 8:1 multiplexer.
Then there is the touch screen interface mode:
Normal conversion mode. Used for regular ADC conversion, initialize ADC by setting ADCCON, and complete conversion by reading and writing ADCDAT0.
Separate X/Y conversion mode. Measure the X/Y coordinates one by one, the X coordinate is stored in ADCDAT0 and an interrupt will be generated, the Y coordinate is stored in ADCDAT1, and an interrupt will also be generated.
Automatic X/Y conversion mode. No need to read X/Y coordinates separately, you can measure X/Y coordinates at one time and read them together, only need to generate one interrupt.
Waiting for interrupt mode. Waiting for pressing or releasing, waiting for Xp to change from high level to low level, or from low level to high level.
Programming Tips
ADC conversion data can be obtained through interrupt or polling. In interrupt mode, there will be a slight delay in obtaining ADC conversion data because there is some additional overhead in entering and exiting the interrupt. In polling mode, you can query ADCCON[15] to determine whether the data conversion is completed.
The recommended method is to use another method. After ADCCON[1] is set to 1, the next conversion starts automatically when the conversion data is read.
The next step is register operation, which controls the opening and closing of the S1-S5 switches through the ADCTSC register.
In addition to register configuration, there is also interrupt configuration.
The ADC/touch screen will generate interrupts, which will be sent to the interrupt controller, and then sent to the CPU. The interrupt controller has a register to enable/disable interrupts.
The figure below is a flowchart about interrupts in the 2440 chip manual.
Checking the chip manual, I found that the ADC and touch screen share the same interrupt source.
Check SRCPND, the 31st bit indicates whether there is an ADC interrupt request. According to the description in the previous figure, this bit will also be set to 1 when a touch screen interrupt occurs, that is, the touch screen interrupt and ADC interrupt share the same interrupt source vector.
There is also the INTMOD register, which selects fast interrupt or normal mode interrupt.
INTMSK register. According to the interrupt execution block diagram, in normal interrupt mode, when an interrupt occurs, the corresponding bit in SRCPND will be set to 1. By setting the INTMSK register, you can choose whether to mask the interrupt request. In fast interrupt mode, the INTMSK register does not work.
INTPND controller indicates that an interrupt is being processed. Similarly, this register only works in IRQ mode and not in FIQ mode.
SUBSRCPND register, bit10 indicates ADC interrupt, bit9 indicates touch screen interrupt.
INTSUBMSK register, bit10 and bit9 are the mask bits for ADC interrupt and touch screen interrupt respectively.
Through SUBSRCPND and INTSUBMSK, we can distinguish whether it is an ADC interrupt or a touch screen interrupt.
To summarize, in IRQ mode, ADC interrupt and touch screen interrupt will be issued together, which can be distinguished by SUBSRCPND, masked by INTSUBMSK, and then sent to SRCPND, and then sent to CPU through INTMSK and INTMOD.
So, how to write a program?
Initialize ADC/TS interface;
Set TS to wait for interrupt mode;
Set interrupts: INTSUBMSK and INTMSK to prevent them from being blocked and not sent to the CPU;
Press to enter TS interrupt: a. Enter automatic acquisition mode; b. Start ADC;
ADC interrupt: a. Read data; b. Enter "wait interrupt mode" again; c. Start the timer;
Timer interrupt: a. If released, end; b. If pressed, jump to 4.b and loop.
Previous article:1.9.3_ADC and touch screen_Resistive touch screen hardware principle_P
Next article:1.9.5_ADC and touch screen_press and release detection_P
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- This problem occurs when setting up the stm8 environment. What is the reason? Thank you
- dsp28335 data space
- [Xianji HPM6750 Review 8] Detailed description of the small twists and turns encountered by SPI peripherals
- MSP430 MCU Development Record (16)
- I posted a thread about icebabycool. He didn't answer the question but laughed at me instead of showing my low IQ. Please punish this kind of rogue behavior severely.
- Help with POE design issues
- [Voice and vision module based on ESP32S3] Material unpacking—ESP32S3 BOX
- PCBA intelligent detection fixture, one-click generation of test reports
- How to choose the right inductor in a switching power supply
- EEWORLD University Hall----Introduction to Isolated Modulator