AT42QTAN0040 ATMEL [ATMEL Corporation], AT42QTAN0040 Datasheet

no-image

AT42QTAN0040

Manufacturer Part Number
AT42QTAN0040
Description
Driving the AT42QT2160 QMatrix Sensor IC
Manufacturer
ATMEL [ATMEL Corporation]
Datasheet
1. Introduction
This application note shows how the AT42QT2160-MMU (QT2160) 16-key QMatrix™
Sensor IC can be connected to a microprocessor to provide touch input functionality.
Example code is provided to demonstrate how easily the QT2160 can be incorporated
into a design. The code can be run “as is” or used as a starting point for QT2160-
based projects. The example compiles to under 1 Kbyte of code including all
necessary I
The example code is written in the C programming language and can easily be
adapted for many processor types. See
complete program.
Figure 1-1.
2. Overview of the QT2160
2.1
The QT2160 is designed for use with up to 16 keys and a slider (constructed from 2
keys up to 8 keys). There are three dedicated general-purpose input/outputs (GPIO),
which can be used as inputs (for example, for mechanical switches) or as driven
outputs. There are eight shared general-purpose outputs (GPO). Pulse switch
modulation (PWM) control can be applied to all GPIO and GPO pins.
Keys are configured in a matrix format that minimizes the number of required scan
lines and device pins. The key electrodes can be designed into a conventional printed
circuit board (PCB) or flexible printed circuit board (FPCB) as a copper pattern, or as
printed conductive ink on plastic film. The QT2160 can be fine tuned to optimize
operation with the electrode design.
Full details of the QT2160 can be found in the QT2160 datasheet, which should be
read in conjunction with this application note.
Host MCU
Driving the AT42QT2160 QMatrix Sensor IC
Introduction
2
C-compatible driver functions.
Circuit Configuration for the Example Project
P0.3
P0.7
P0.6
Vdd
CHANGE
SCL
SDA
QT2160
Section 6 on page 8
GPIO3
GPO3
GPO2
GPO1
GPO0
for a listing of the
5-Key Slider
(keys 0
8 Discrete Keys
(keys 8
QMatrix Key
4)
Vdd
Array
15)
Driving the
AT42QT2160
QMatrix Sensor
IC
Application Note
AT42QTAN0040
10702A–AT42–07/08

Related parts for AT42QTAN0040

AT42QTAN0040 Summary of contents

Page 1

... Section 6 on page 8 for a listing of the GPIO3 GPO3 GPO2 GPO1 GPO0 CHANGE SCL SDA 8 Discrete Keys 5-Key Slider (keys 0 QT2160 Driving the AT42QT2160 QMatrix Sensor IC Application Note Vdd AT42QTAN0040 (keys 8 – 15) – 4) QMatrix Key Array 10702A–AT42–07/08 ...

Page 2

QT2160 Host Interface The QT2160 connects to a host controller by means uses a common two-wire connection between the host QT2160 and other I devices in the system. The bus protocol takes care of all addressing ...

Page 3

Interface Timing Figure 3-1 in its sense status by driving the CHANGE pin low. In this context, sense status includes bytes 2 through 6 of the address map. In response to the QT2160 driving CHANGE low, the host reads ...

Page 4

During initialization, the program establishes communication with the QT2160 and then sets it up for the required operating mode. In the main loop, the program monitors the CHANGE pin. If the CHANGE pin is low, the program reads the five ...

Page 5

I C-compatible Driver 2 5.1 I C-compatible Communication 2 I C-compatible communication is a major aspect of any program involving the QT2160. Some form of I Most current microprocessors include a hardware I be programmed to efficiently handle ...

Page 6

Table 5-1. Macro SetLoSDA FloatSDA SendSTART SendSTOP SendCLOCK 5.4 SendByte() The SendByte() function transmits a single byte onto the I supplied as an input parameter. SendByte() returns I2C_OK if the byte is acknowledged or I2C_FAIL if a NACK is returned. ...

Page 7

The WriteQtI2c() function writes one or more bytes to the QT2160 as specified in the datasheet. It accepts four input parameters: • SlaveAddress: The QT2160 I • WriteAddress: The address of the first QT2160 register to be written. • WriteLength: ...

Page 8

Source Code /*===================================================================================== Project: =====================================================================================*/ typedef unsigned char uint8_t; enum { /* QT2160 registers */ QT_CHIP_ID = 0, QT_KEY_STATUS_2, QT_RESET, QT_POS_DRIFT_COMP, QT_SLIDER_CONTROL, QT_KEY_BL = 54, QT_GPO_PWM, QT_COMM_CHG_KEYS_1, }; #define QT2160_ID #define QT_STATUS_SDET #define QT_STATUS_RES #define QT_GPIO_1 #define QT_GPIO_2 #define ...

Page 9

Function: main() =====================================================================================*/ void main ( void ) { /*------------------------------- Initialisation -------------------------------------*/ /* (1) Establish communication with the QT2160 touch-sensor */ /* wait for successful transfer at the QT2160's address - Read Chip-ID */ while ( !ReadQtI2c (QT2160_I2C_ADDRESS, QT_CHIP_ID, ...

Page 10

QT2160 LEDs */ WriteQtI2c ( QT2160_I2C_ADDRESS, QT_GPO_DRIVE, 1, &QtStatus[ Update the PWM level if the slider is touched */ if (QtStatus[0] & QT_STATUS_SDET) WriteQtI2c ( QT2160_I2C_ADDRESS, QT_PWM_LEVEL, 1, &QtStatus[3] ); ...

Page 11

Function: SendByte() Input: Byte to send Output: I2C_OK if device ACKs, I2C_FAIL if device NACKs ====================================================================================*/ uint8_t SendByte ( uint8_t TxByte ) { uint8_t i,b, Result = I2C_OK; for ( < 8; b++) { if ( ...

Page 12

SDA ) RxByte |= 1; SetLoSCL AckBit ) /* send ACK bit */ SetLoSDA else SetHiSDA SendCLOCK return RxByte; } /*===================================================================================== Function: WriteQtI2c() Executes multi-byte write to QT-device Input: SlaveAddress = Device address on the ...

Page 13

Function: ReadQtI2c() Executes multi-byte read from QT-device Input: SlaveAddress = Device address on the I2C bus ReadAddress = Register address ReadLength = Number of bytes to read ReadPtr = Pointer to byte array for read-data Output: I2C_OK if transfer ...

Page 14

Headquarters Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Disclaimer: The information in this document is provided in connection with Atmel and QRG Ltd. products. No license, express or implied, by estoppel ...

Related keywords