1.9.4_ADC and touch screen_S3C2440 touch screen interface_P

Publisher:seanxnieLatest update time:2021-08-17 Source: eefocusKeywords:ADC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

insert image description here

Check the 2440 chip manual to see how the touch screen works.

insert image description here

First, we can choose which channel to control through the 8:1 multiplexer.

insert image description here

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.

insert image description here

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.

insert image description here

insert image description here

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.

insert image description here

The figure below is a flowchart about interrupts in the 2440 chip manual.

insert image description here

Checking the chip manual, I found that the ADC and touch screen share the same interrupt source.

insert image description here

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.

insert image description here
insert image description here

There is also the INTMOD register, which selects fast interrupt or normal mode interrupt.

insert image description here
insert image description here

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.

insert image description here
insert image description here

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.

insert image description here
insert image description hereSUBSRCPND register, bit10 indicates ADC interrupt, bit9 indicates touch screen interrupt.

insert image description here
insert image description here
insert image description here

INTSUBMSK register, bit10 and bit9 are the mask bits for ADC interrupt and touch screen interrupt respectively.

insert image description here

Through SUBSRCPND and INTSUBMSK, we can distinguish whether it is an ADC interrupt or a touch screen interrupt.

insert image description here

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.

Keywords:ADC Reference address:1.9.4_ADC and touch screen_S3C2440 touch screen interface_P

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

Latest Microcontroller Articles
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号