S3C2440 Test Procedure (V) Touch Screen Experiment

Publisher:Chunjie2022Latest update time:2016-12-06 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

          The detection principle of resistive touch screen is that after touching, the upper and lower conductive layers come into contact, changing the voltage output, and after A/D conversion, it becomes the X, Y coordinates of the point.
          Initialize AD and touch port:
          void TouchSrceen_Test(void)

         {

                rADCDLY = 50000; //(1/3.68MHz)*50000 = 13.56ms
  Note: Before ADC conversion, the external clock X-tal clock: 3.68MHz is used,
                                and then GLK: 50MHz is used

                rADCCON = (1<<14)|(prescaler<<6);

                Note: bit[14]: 0--disable ADC 1--enable ADC bit[13:6]: prescaler = 9 ADC fleq = 50MHz/(9+1) = 5MHz

                Uart_Printf("\nTouch Screen test\n");

                rADCTSC = 0xd3;//waiting for interrupt Mode
  Note: bit[1:0]: 11--waiting for interrupt Mode
   bit[2]: 0--Normal ADC 1--Auto Sequential measurement of X-position,Y-position
   bit[3]: 0--XP pull-up enable 1--XP pull-up disable
   bit[4]: 0--XP output driver enable 1--XP output driver disable
   bit[5]: 0--XM output driver disable 1--XM output driver enable
   bit[6]: 0--YP output driver enable 1--YP output driver disable
   bit[7]: 0--YM output driver disable 1--YM output driver enable
   bit[8 ]: 0--stylus down interrupt signal 1--stylus up interrupt signal

                pISR_ADC = (int)ADC_TCTest;

                rINTMSK = ~(1<<31); //clear ADC MASK bit

                rINTSUBMSK = ~(1<<9); //clear TouchScreen MASK bit

       }

       void __irq ADC_TCTest(void)

       {

                U32 saveADCDLY;

                if(rADCDAT0 & 0x8000) //bit[15]:0--stylus down 1--stylus up

                {

                      rADCTSC &= 0xff; //clear bit[8]:0 stylus down 1--stylus up

                }

                rADCTSC = (1<<3)|(1<<2); //disable XP pull-up

                 //auto sequential measurement of XY position

                saveADCDLY = rADCDLY;

                rADCDLY = 40000; //(1/50MHz)*40000=0.8ms
  Note: As shown in the figure below, switch to GCLK when X,Y conversion is required.

  S3C2440 Test Program (V) Touch Screen Experiment - lastnight1034 - lastnight1034's Blog

 

                 rADCCON |= 0x01; //start ADC

                 while(rADCCON & 0x1); //waiting for ADC startup

                 while(!(rADCCON & 0x8000)); //waiting for ADC end

                 while(!(rSRCPND & (0x1<<31)));//waiting for interrupt bit=1

                 xdata = rADCDAT0 & 0x3ff;

                 ydata = rADCDAT1 & 0x3ff;
   Note: Read the X, Y coordinate data in the buffer

                 if(((xdata-xdata_save > 5)||(xdata-xdata_save < -5))\

                 ||((ydata-ydata_save > 5)||(ydata-ydata_save < -5)))

                 {

                         Uart_Printf("X_value = %d,Y_value = %d,X_data = %d,Y_data = %d\n",\
                                        xdata,ydata,xdata_save,ydata_save);

                 }

                 xdata_save = xdata;

                 ydata_save = ydata;

                 
                         rSUBSRCPND |= (1<<9);

                 rINTSUBMSK =~(1<<9);

                 rSRCPND |= (0x1<<31);

                 rINTPND |= (0x1<<31);

                 rINTMSK = ~(0x1<<31);

   Note: Clear all interrupt-related flags to prepare for the next interrupt

                         rADCTSC = 0xd3; //waiting for interrupt

                 rADCTSC |= 0x100; //stylus up

                 while(!(rSUBSRCPND & (1<<9))); //waiting for stylus up interrupt bit=1

 
  Uart_Printf("The pen has stylus up.");

  rSUBSRCPND |= (1<<9);

  rINTSUBMSK =~(1<<9);

  rSRCPND |= (0x1<<31);

  rINTPND |= (0x1<<31);

  rINTMSK = ~(0x1<<31);
  Note: Clear all interrupt-related flags to prepare for the next interrupt

  rADCDLY = saveADCDLY;

  rADCTSC &= ~0x100; //stylus down

        

}


Keywords:S3C2440 Reference address:S3C2440 Test Procedure (V) Touch Screen Experiment

Previous article:Color display principle of TFT LCD
Next article:S3C2440 Test Program (IV) External Interrupt Experiment

Recommended ReadingLatest update time:2024-11-15 14:51

S3C2440 bare metal -------I2C_I2C protocol and EEPROM
Although I have used the I2C protocol many times in my work and I am familiar with it, I still want to write down some simple notes.  
[Microcontroller]
S3C2440 bare metal -------I2C_I2C protocol and EEPROM
S3C2440⑤ | S3C2440 clock system architecture and experiments
1. Clock architecture Simplify it as shown in the figure: 1.1.Clock source selection There are two clock sources for S3C2440: External crystal oscillator (OSC) External clock signal (EXTCLK) The clock source of S3C2440 is determined by the mode control pins O
[Microcontroller]
S3C2440⑤ | S3C2440 clock system architecture and experiments
Linux2.6.32 kernel porting s3c2440 - DM9000 network card driver porting
reference: http://caiming1987612.blog.163.com/blog/static/118556676200961752714307/ http://blog.chinaunix.net/u1/34474/showart_401078.html http://hi.baidu.com/%D3%F3%C4%E0%C4%EA%B8%E2/blog/item/6256fea7bfceac98d0435819.html Timing diagram and pin connection: http://blog.chinaunix.net/u1/57901/sho
[Microcontroller]
I2C Bus Driver
#include "linux/kernel.h" #include "linux/module.h" #include "linux/i2c.h" #include "linux/init.h" #include "linux/time.h" #include "linux/interrupt.h" #include "linux/delay.h" #include "linux/errno.h" #include "linux/err.h" #include "linux/platform_device.h" #include "linux/pm_runtime.h" #include
[Microcontroller]
I2C Bus Driver
Linux-2.6.14 transplant: NET: Registered protocol family 1 stuck
After modifying the kernel source code and adding the yaffs source code, I started make and the following error occurred: U-Boot 1.1.6 (Mar 21 2012 - 07:03:29) DRAM:  64 MB Flash:  2 MB NAND:  256 MiB *** Warning - bad CRC or NAND, using default environment In:    serial Out:   serial Err:   serial Hit
[Microcontroller]
Porting s3c2440 ads program to keil (Part 3) Preliminary completion
What if I change the parameter configuration? Then compile again to package errors As follows In fact, we are close to here. In the article "Transplanting s3c2440 ads program to keil (Part 2)", we saw this netizen who provided a method and several file download addresses. http://download.csdn.net/detail/googl
[Microcontroller]
Porting s3c2440 ads program to keil (Part 3) Preliminary completion
A Design of Digital FM Radio Based on WinCE6.0
    This design uses the digital radio chip Si4730 to provide a good solution for integrating FM functions into intelligent systems based on WinCE6.0. This solution implements functions such as full-frequency manual and automatic channel search. 1 The system design process based on WinCE6.0     is shown in Figure 1. T
[Microcontroller]
A Design of Digital FM Radio Based on WinCE6.0
Commonly used position-independent and position-dependent instructions in S3C2440 assembly
After looking at the S3C2440 bootloader for a while, I feel B and BL instructions are often used in bootloder programs. They are position-independent codes. The target address in the instruction is represented by an offset based on the current PC, which is independent of the absolute address value assigned to the addr
[Microcontroller]
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号