Application example of touch screen on S3C2410

Publisher:huanguuLatest update time:2021-02-03 Source: eefocusKeywords:S3C2410 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction


With the popularity of personal digital assistants (PDAs) and thin-capacity computers, touch screens are becoming more and more common in our lives as a medium for terminal and user interaction. Touch screens are divided into resistive, capacitive, surface acoustic wave and infrared scanning types, and the most commonly used is the 4-wire resistive touch screen.


This paper is based on the touch screen interface of Samsung's ARM9 core chip S3C2410, and forms the hardware foundation by connecting an external 4-wire resistive touch screen. On this basis, a touch screen surface drawing board program is developed.


1 Touch screen principle

The circuit principle of S3C2410 connected to a 4-wire resistive touch screen is shown in Figure 1.


The entire touch screen consists of a module-wise resistance ratio and a longitudinal resistance line. The four control signals nYPON, YMON, nXPON, and XMON control the on and off of four MOS tubes (S1, S2, S3, and S4). S3C2410 has eight analog input channels. Among them, channel 7 is used as the X coordinate input of the touch screen interface (AIN[7] in Figure 1), and channel 5 is used as the Y coordinate input of the touch screen interface (AIN[5] in Figure 1). The circuit is shown in Figure 2.


Before connecting to the S3C2410 touch screen interface, they all pass through a RC low-pass filter to remove the coordinate signal noise. The filtering here is very important. If the interference in the signal transmitted to the S3C2410 analog input interface is too large, it will be detrimental to the subsequent software processing. During the sampling process, the software only needs to set the special register, and the S3C2410 touch screen controller will automatically control the touch screen interface to open or close each MOS tube, and complete the X coordinate point acquisition and Y coordinate point acquisition in sequence.


2 S3C2410 touch screen controller


The S3C2410 touch screen controller has two processing modes:


①X/Y position conversion mode. The touch screen controller includes two control stages, the X coordinate conversion stage and the Y coordinate conversion stage.


②X/Y position automatic conversion mode. The touch screen controller will automatically convert the X and Y coordinates.


This article uses the X/Y position automatic conversion mode.


3 S3C2410 touch screen programming


Since the selection and optimization of parameters in the touch screen program requires multiple experiments, and adding operating system test parameters, each compilation and download takes too much time, which is not easy to conduct experiments, so we directly write bare metal touch screen programs. Samsung has opened the S3C2410 test program 2410test (which can be downloaded from the Samsung website), and provides a program example ts_auto.c for the automatic conversion mode of the touch screen interface. Based on this example, this article writes a touch screen drawing board program - drawing the traces of the touch pen on the display screen.


In view of the noise generated when sampling coordinate points, this paper adopts a noise filtering algorithm and writes a corresponding noise filtering program to filter out interfering sampling points. The processing flow of the entire touch screen drawing board program is shown in Figure 3.



3.1 Program Initialization


Initialize the touch screen controller to the automatic conversion mode. The value of the register ADCDLY needs to be selected according to the specific test. You can run the program provided in this article to see the effect of drawing lines to select specific parameters. The touch screen interrupt handler Adc_or_TsAuto determines whether the touch screen is pressed. If the touch screen is pressed, assign the global variable Flag_Touch to Touch_Down, otherwise assign it to Touch_Up.


Initialize the pulse width modulation timer (PWM TIMER), select timer 4 as the clock, define 10ms interrupt once, and provide the touch screen sampling time base, that is, 10ms touch screen sampling once. In the counter interrupt handler Timer4Intr, if Flag_Touch is assigned to Touch_Down, the global variable gTouchStartSample is set to control the touch screen sampling.


Then clear the touch screen interrupt and timer interrupt mask bits, accept the interrupt response, and the timer starts timing.


3.2 Touch screen sampling procedure


If gTouchStartSample is TRUE, the touch screen interface starts sampling the analog values ​​of coordinates X and Y. The appropriate number of acquisitions is selected based on the experiment. This article uses 9 acquisitions, which are recorded in the ptx[TouchSample] and pty[TouchSample] arrays respectively, where TouchSample is the number of acquisitions.


In order to reduce the amount of calculation, ptx[] and pty[] are divided into three groups and the average values ​​are stored in px[3] and py[3]. Here we take the processing of X coordinate as an example:


px[0]=(ptx[0]+ptx[1]+ptx[2])/3;


px[1]=(ptx[3]+ptx[4]+ptx[5])/3;


px[2]=(ptx[6]+ptx[7]+ptx[8])/3;


Calculate the difference between the above three sets of data:


dlXDiff0=px[0]-px[1];


dlXDiff1=px[1]-px[2];


dlXDiff2=px[2]-px[0];


Then take the absolute value of the above difference, and the result is referred to as the absolute difference:


dlXDiff0=dlXDiff0>0?dlXDiff0:-dlXDiff0;


dlXDiff1=dlXDiff1>0?dlXDiff1:-dlXDiff1;


dlXDiff2=dlXDiff2>0?dlXDiff2:-dlXDiff2;


Determine whether the color pair differences calculated above all exceed the difference threshold. If the three absolute differences all exceed the threshold, the sampling point is determined to be a wild point, the sampling point is discarded, and the program returns to wait for the next sampling. The difference threshold needs to be obtained based on experimental tests, and this article takes the value of 2.


Find the two sets of data with the smallest absolute difference, average them, and assign them to tmx:


if(dlXDiff0

if(dlXDiff2

tmx=((px[0]+px[2]>>1);


}


else{


tmx=((px[0]+px[1])>>1);


}


}


else if(dlXDiff2

tmx=((px[0]+px[2])>>1);


}


else{


tmx=((px[1]+px[2])>>1);


}




The function Touch_Coordinate Conversion converts the touch screen sampling value into display coordinates. There are different conversion methods according to different hardware. The touch screen sampling coordinates and display coordinates are shown in Figures 4 and 5. Among them, TOUCH_MAX_X and TOUCH_MIN_X are the maximum and minimum values ​​of the touch screen X coordinate sampling value; the same is true for the Y coordinate. You can run the program in this article and use the touch pen to obtain the maximum and minimum sampling values ​​at the four corners of the touch screen. The 320×240 TFT screen is used here, so the TOUCH_X value is 320. The following is the conversion program for the X coordinate:


Touch_CoordinateConversio(int*px){


TmpX=(tmx>=TOUCH_MAX_X)?(TOUCH_MAX_X):*px;


TmpX-=TOUCH_MIN_X;


TmpX=(TmpX)?TmpX:0;


*px=(TmpX*TOUCH_X)/(TOUCH_MAX_X-TOUCH_MIN_X);


}


3.3 Coordinate filtering procedure


The coordinate filtering program Touch_Pen_filtering considers that there are three types of touch screen operations in the human-machine interface:


*The position of the stylus on the touch screen remains unchanged;


*The stylus slides continuously on the touch screen;


*The stylus jumps wildly on the touch screen.


Assume that three consecutive sampling times are T1, T2, and T3 (T3> T2> T1), and the sampling interval is 10ms. Since the sampling interval is much smaller than the human reaction time, in the first two operation modes, if the sampling point is valid, the sampling values ​​at T1 and T3 are averaged. The average value compared with the sampling value at T2 is generally not greater than a certain threshold, otherwise the sampling point is judged to be a wild point. For the third mode, the sampling point data will have a large jump. The data during the jump process is unstable. Although the data is recorded, it is judged to be an invalid sampling point. Therefore, a static array x[2] needs to be defined in the program to record the two adjacent sampling data. Only when the current and subsequent data remain stable for a period of time, the sampling point is considered valid. The interval threshold FILTER_LIMIT used in the program needs to be selected through experiments. Only the filtering process of the X coordinate is given here.


//*px is the sampling value at time T3, count is a static variable that records the number of consecutive valid sampling points, marking the duration of the current data stability. Once it is found to be greater than //FILTER_LIMIT, the value of count will start counting from 0 again.


Int Touch_Pen_filtering(int *px){


BOOL retVal;


Static int count=0;


count++;


//If the number of consecutive valid sampling points is greater than 2, start the filtering algorithm


if(count>2){


count=2;


//Average the sampling value at time T3 and the sampling value at time T1


TmpX=(x[0]+*px)/2;


//Calculate the difference between the average value and the sampling value at time T2


dx=(x[1]>TmpX)?(x[1]-TmpX):(TmpX-x[1]);


//If the difference is greater than the threshold, it means that the sampling value of T3 is invalid, and it is judged as a wild point and the return value is FALSE. In order to avoid excessive jumps, it is assumed that the touch pen coordinates have changed, and the sampling value at time T2 is used to replace the current sampling point. At the same time, the data in the static variable x[] remains unchanged, and count starts to record the number of consecutive valid sampling points again.


if((dx>FIL TER_LIMIT)){


*px=x[1];


retVal=FLASE;


count=0;


}


//Otherwise, the sampling point is valid and the return value is TRUE. The sampling point of T3 is recorded in x[1], and the sampling point of T2 is moved to x[0]


else{


x[0]=x[1];


x[1]=*px;


retVal=TRUE;


}


}


else{


//When the number of consecutive valid sampling times is less than 2, the sampling value of T3 is recorded in x[1], and the sampling value of T2 is moved to x[0] without filtering.

[1] [2]
Keywords:S3C2410 Reference address:Application example of touch screen on S3C2410

Previous article:Implementation of Trusted Computing Based on ARM
Next article:Introduction to ARM processor registers

Recommended ReadingLatest update time:2024-11-16 21:35

How to use U-boot to implement Nand/Nor dual boot
  When porting u-boot, most people use Nand flash boot or Nar flash boot. In this way, u-boot can only be used in Nand flash or Nor flash. So how can we make our u-boot work in Nand flash or Nor flash?   First, let's talk about u-boot. u-boot is a program executed when the system starts. This program is usually stor
[Microcontroller]
How to use U-boot to implement Nand/Nor dual boot
Application example of touch screen on S3C2410
introduction With the popularity of personal digital assistants (PDAs) and thin-capacity computers, touch screens are becoming more and more common in our lives as a medium for terminal and user interaction. Touch screens are divided into resistive, capacitive, surface acoustic wave and infrared scanning types, and
[Microcontroller]
Application example of touch screen on S3C2410
Design of WLAN Intelligent House Control Terminal Based on S3C2410
1 Introduction The gradual penetration of information technology in the construction industry has led to the rapid development of smart buildings, smart homes and even smart communities. This emerging industry integrates modern construction technology, electronic technology, communication technology and control tech
[Microcontroller]
Design of WLAN Intelligent House Control Terminal Based on S3C2410
Some details of the differences between s3c2410 and s3c2440
Both socs are arm920, cpuid is 0x41129200, and many register settings are the same, but if you want to directly use the bootloader and kernel of 2410 on 2440, it will definitely go wrong. There are many articles like this on the Internet, most of which only mention macro aspects, such as camera driver, main frequency,
[Microcontroller]
Getting Started with S3c2410 Bare Board Program---Flowing Light
I am new to arm, so I wrote a few small practice programs, recorded here. Includes: running water lamp, single button, pwm driven buzzer, serial port and PC communication Development board s3c2410, development environment realview + h-jtag Without further ado, let’s start the first program. The study of bare boa
[Microcontroller]
S3c2410 bare board programming introduction --- single button (I)
That's a bit of an introduction. Okay, let's start learning something a little more complicated and write a single-button program. Some people may laugh, this is complicated? Indeed, it is relatively simple to have only one button, but the key is that we need to use this button to lead to the interrupt processing pa
[Microcontroller]
ARM S3C2410 Learning Notes
1. Introduction to S3C2410 processor 2410 is a 16/32-bit RISC embedded system microprocessor based on the ARM920T core from Samsung, mainly for handheld devices and low-power, cost-effective applications. The frequency reaches 203Mhz. The ARM920T core consists of three parts: the ARM9TDMI core, the memory management u
[Microcontroller]
Implementation of S3C2410 Quick Start
Embedded systems have strict requirements on functions, reliability, cost, volume, power consumption, etc. Various RISC microprocessors based on ARM architecture have flexible characteristics and powerful performance, and have been widely used in embedded systems. ---S3C2410 is a processor designed by Samsung based
[Microcontroller]
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号