Design of I2C touch screen based on embedded system

Publisher:ShimmeringStarLatest update time:2018-02-19 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

      introduction

  With the development of computer-related technologies, ARM is a well-known company in the microprocessor industry. It has designed a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. The technology has the characteristics of high performance, low cost and low energy consumption. It is applicable to many fields, such as embedded control, consumer/educational multimedia, DSP and mobile applications. ARM is a company specializing in the design and development of chips based on RISC technology. As an intellectual property supplier, it does not directly engage in chip production. It relies on the transfer of design licenses to cooperative companies to produce chips with different characteristics. Major semiconductor manufacturers in the world purchase ARM microprocessor cores designed by ARM. The embedded Linux system has the characteristics of open source code, stable kernel and scalability, which attracts the attention of many commercial companies and free software developers and becomes one of the indispensable operating systems in the field of embedded systems.


  1 Working principle of resistive touch screen

  The touch screen is installed at the front end of the display screen, and is mainly composed of two parts: the touch screen detection component and the touch screen controller. According to the working principle and the medium of information transmission, the touch screen can be divided into resistive, capacitive, infrared and surface acoustic wave types. When an object is pressed on the touch screen, pressure is generated, so that the two conductive layers of the touch screen are connected. Once the touch screen detection component detects the user's touch position, the obtained position information is sent to the touch screen controller TSC2007, and the write signal is processed to convert the voltage signal into a digital signal, and at the same time sent to the S3C2440 processor in an interrupt manner to calculate the touch point coordinates.

  2 Hardware Structure

  TSC2007 is a new generation of 4-wire touch screen controller launched by Texas Instruments (TI) in the United States. When used in conjunction with a touch screen, once it detects a pen or finger touching the screen, it can quickly obtain the position signal of the point, thereby achieving the purpose of addressing on the touch screen surface.

  TSC2007 is a typical step-by-step approximation A/D converter. Its structure is based on capacitor redistribution and includes a sampling/holding function. The pins of TSC2007 are fully compatible with those of TPSC2003. It has three functions: on-chip temperature measurement, touch pressure measurement, and preprocessing. The I2C interface of TSC2007 performs data transmission and communication in standard mode, high-speed mode, and ultra-high-speed mode. In order to be compatible with other ARM chips, the design does not use the built-in A/D channel of S3C2440. Instead, it adopts the method of external expansion controller TSC2007 to communicate with S3C2440 through I2C bus. Therefore, GPE14 and GPE15 of S3C2440 are used as SCL and SDA lines of I2C bus respectively in the design. The touch screen controller interface circuit is shown in Figure 1. The SDA and SCL lines in the figure are both bidirectional.

 

  3 Touch screen driver

  In Linux system, device driver is a set of related functions, including device service subroutines and interrupt handlers. The device service subroutines contain all device-related codes. Each device service subroutine only handles one device or closely related devices, accepts abstract commands from device-independent software and executes them. The device driver uses the structure file_operations to connect with the file system. The entry functions of various operations of the device are placed in the structure file_operations, including open(), release(), read() and write() interfaces, which simplifies the writing of the driver. In this way, the application does not have to consider whether it is operating a device or an ordinary file. It can be treated as a file and has a very clear and unified I/O interface. The file_operations structure of the touch screen is defined as follows:

 

  The main function of this structure is to provide a consistent interface for different devices. For example, in the application, read operations on different devices all use the read function, and write operations all use the write function. Therefore, the actual work of writing a touch screen driver is not complicated.

  3.1 Driving Workflow

  First, initialize the touch screen controller, then initialize the pulse width modulation timer ( PWM  TIMER). You can select timer 4 as the clock and define a 10 ms interrupt to provide the touch screen sampling time base, that is, the touch screen samples once every 10 ms. Then map the touch screen interrupt vector and the timer interrupt vector to the response program. The touch screen interrupt handler determines whether the touch screen is pressed. If the touch screen is pressed, the global variable Flag_Trouch is assigned to Touch_Down, otherwise it is assigned to Touch_Up. If the timer interrupt handler determines that Flag_Touch is assigned to Touch_Down, the global variable StartSample is set to control the touch screen sampling. Then the system obtains the sampling value through S3C2440_get_xy() and processes the obtained touch screen data. Next is the calibration of the touch screen, and finally the release of the interrupt and the uninstallation of the registration module. The specific touch screen driver workflow is shown in Figure 2.

 

 

3.2 Device initialization module


  The main functions of the device initialization module are: initializing the device, registering the device with the kernel, etc. The specific implementation functions are as follows:

 



The initialization module uses the request_IRQ function   provided by the kernel to register the interrupt numbers of the touch pen's press and release, thereby linking the interrupt number with the interrupt service function; uses the devfs_register_chrdev function to register a character device with the system; and finally registers the timer interrupt to control the data sampling of the touch screen.

  3.3 Obtaining sampling values

  First, start the A/D conversion of TSC2007. After waiting for a while, call the S3C2440_get_xy () function, which is used to obtain the position of the touch screen. First, obtain the x coordinate value from one channel of TSC2007, and then obtain the y coordinate value from another channel to determine whether the returned touch point coordinate value is within the valid range. If it is within the valid range, the sampling flag ts_pressure=1, if it is not within the valid range, the sampling flag ts_pressure=0. In the read function, by calling copy_to_user (buffer, dbuf, length), the kernel space data can be copied to the user space.

  3.4 Processing of sample values

  The function Touch_Coordinate Conversion converts the touch screen sampling value into display coordinates, where TOUCH_MAX_Y and TOUCH_MIN_Y are the maximum and minimum values ​​of the touch screen X coordinate sampling value; the same is true for the X coordinate. If a 320×240 TFT screen is used, the Y coordinate conversion procedure is as follows:

 

  3.5 Touch screen calibration

  In actual applications, touch screens are usually used as input devices in conjunction with display screens. It is necessary to map the coordinates obtained from the touch screen sampling to the display coordinates of the screen. The touch screen design in this paper adopts the three-point calibration method. Compared with the two-point calibration, the three-point calibration model takes into account the transformation and rotation, which is closer to the actual situation. In the application, three independent sampling points that are far apart and not on the same line are first selected as calibration inputs. Their corresponding touch screen sampling coordinates are P0 (x0, y0), P1 (x1, y1), P2 (x2, y2), and the display coordinates are PD0 (xD0, yD0), PD1 (xDl, yD1), PD2 (xD2, yD2). Two points P and PD in the rectangular coordinate plane, P is defined as the coordinate point of the touch screen space, and PD is the coordinate point of the display screen space. P can be rotated, scaled and translated to obtain the PD coordinates. There is a linear relationship between PD and P points: xD=Ax+By+C, yD=Dx+Ey+F. For the same device, A, B, C, D, E, and F are constants, called calibration constants. Therefore, when calibrating the touch screen, you only need to solve these 6 constants to achieve the touch screen space calibration.

  Conversion to display space.

  3.6 Interrupt release and registration module unloading

  In the design, s3c2440_ts_cleanup_module0 is called to release the interrupt and uninstall the device, and they are released during the initialization process. The specific interface functions devfs_register_chrdev() for the interrupts of IRQ_TIMER4, IRQ_ADC_DONE, and IRQ_TC and the character device are as follows:

 

  4 Conclusion

  In this paper, the touch screen driver development based on S3C2440 is based on the compatibility with other ARM chips. Instead of using the A/D channel of ARM itself, the touch screen controller TSC2007 is expanded. The initialization of TSC2007 is mainly to initialize the I2C interface connection between TSC2007 and S3C2440. In the driver process, if the touch pen is pressed, the interrupt handler is entered to read the x and y coordinates. A copy_to_user (buffer, dbuf, length) function is set in the sampling function to send the data continuously measured from the touch screen to the storage area.

  Combined with the actual hardware platform, this I2C bus interface touch screen design based on the embedded Linux operating system adopts the method of processing sampled data and uses an improved calibration method, so that the touch screen driver can better meet the actual requirements. ARM is a well-known company in the microprocessor industry, designing a large number of high-performance, low-cost, low-energy RISC processors, related technologies and software. The technology has the characteristics of high performance, low cost and low energy consumption. It is suitable for a variety of fields, such as embedded control, consumer/educational multimedia, DSP and mobile applications.


Reference address:Design of I2C touch screen based on embedded system

Previous article:Realization of real-time network communication and LCD display in ARM11 embedded system
Next article:Realization of Embedded Serial Communication Based on S3C2410 of ADS

Recommended ReadingLatest update time:2024-11-16 20:47

Interface design of bank queuing system based on I2C bus
This paper takes the existing queueing system of the bank as an example and proposes the interface design of the single-chip microcomputer queueing system based on the IIC bus. Through the simulation test of the system, it not only simplifies the design circuit, reduces the circuit board area, saves components in the
[Microcontroller]
Interface design of bank queuing system based on I2C bus
mini2440 simple touch screen driver
After the module is loaded, the horizontal and vertical AD conversion results are printed out. There is no coordinate conversion. It is just for learning the programming method of the touch screen interface. The code is recorded as follows: #include linux/errno.h #include linux/kernel.h #include linux/module.h #i
[Microcontroller]
PIC microcontroller i2c program
#include pic.h #define uchar unsigned char #define uint unsigned int #define add 0xaa __CONFIG(0xc3e4); __CONFIG(0xffff); #define DS1302 RC2 //Define to turn off the DS1302 clock chip so that the RC4 RC3 IO ports can be used for AT24C02 control. const uchar ee_data ={1,2,3,3,2,1}; uchar read_data ; const uchar table
[Microcontroller]
I2C Learning STC15F204EA---GPIO Port Simulation--Simple Control PCF8574AT
Be sure to add a pull-up resistor of about 4.7K----the address will be different due to different device types! ------------------------------------------------------i2c.h----------Header file----------------------- #ifndef __I2C_H #define __I2C_H #define I2C_SCL_1()  P32=1 //SCL = 1  #define I2C_SCL_0()  P32=0 //SC
[Microcontroller]
I2C Learning STC15F204EA---GPIO Port Simulation--Simple Control PCF8574AT
Linux-2.6.32.2 kernel porting on mini2440 (XII) --- porting I2C EEPROM driver
Migration environment  1. Host environment: CentOS 5.5 under VMare, 1G memory. 2. Integrated development environment: Eclipse IDE 3. Compilation environment: arm-linux-gcc v4.4.3, arm-none-linux-gnueabi-gcc v4.5.1. 4. Development board: mini2440, 2M nor flash, 128M nand flash. 5.u-boot version: u-boot-2009.08 6. Linux
[Microcontroller]
Hardware I2C of STM32F407
I am using the firmware library for STM32. The hardware module parameters must be configured before use. The I2C configuration is as follows: void IIC_Config(void) {     GPIO_InitTypeDef GPIO_InitStructure;     I2C_InitTypeDef I2C_InitStructure;     RCC_ClocksTypeDef rcc_clocks;     /* GPIO Peripheral clock enable *
[Microcontroller]
Introduction to Virtual I2C Bus Serial Display Circuit
This article mainly introduces the virtual I2C bus serial display circuit, including the SAA1064 pin function introduction, hardware circuit design, on-chip programmable functions and program examples.    1. SAA1064 pin function   ① VDD, VEE: power supply, ground terminal. Power supply 4.5~15V;   ② P1~P16: Segment
[Analog Electronics]
Introduction to Virtual I2C Bus Serial Display Circuit
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号