Based on the application design needs, the user needs to select the right library variant and the configuration to be used along with the variant. This section illustrates the steps required to select the right QMatrix acquisition method library variant and configuration for your application. QMatrix acquisition method library Variants are offered for IAR and AVR-GCC tool chains. First step is to select the compiler tool chain for which the libraries are required.
There are specific library variants distributed for each microcontroller. For your design, you would need the following information to select the correct library variant
Device to be used for the design
The number of touch sensing channels needed by the application – Then identify the Maximum number of channels required for the design that are supported by the library.
Number of X lines to be used in the design
The ports on which your design permits to have the X lines.
The X lines can be spread on a maximum of three ports, the more ports used the more is the code memory requirement by the library.
Number of Y lines to be used in the design
The port-pins ports on which your design permits to have the Y lines.
Do you need support for Rotors and/or Sliders in your design
If yes, how many rotors/sliders would be needed?
Based on a) above, identify the maximum number of rotors sliders that the library supports.
Which compiler platform you intend to use to integrate the libraries – IAR or AVR -GCC
Follow the steps listed below to arrive at the right library variant
Select the device from the list of supported devices
Select the right library variant for the device selected from the selection guide available in C:\ Program Files\Atmel\Atmel_QTouch_Libraries_5.x\Library_Selection_Guide.xls
Each variant supports
a specific number of channels,
Supports a specific configuration of X x Y matrix pins ( eg 4 x 2 for 4 - X pins & 2 - Y pins )
has support for Rotor / Slider ( either supported or not )
support is available for IAR and/or GCC compiler tool chain
support for specific number of rotors sliders.
Define the constants and symbol names required
The next step is to define certain constants and symbols required in the host application files where the touch API is going to be used. These values are derived from the parameters defined in step 2 for your application.
The constant/symbol names are as listed in the table below
The constant/symbol definitions can be placed in any of the following
In the user’s ‘C’ file prior to include touch_api.h in the file.
Modifying the defines in a touch_config.h available in the project folder.
Symbol / Constant name |
Range of values |
Comments |
---|---|---|
_QMATRIX_ |
Symbol defined to indicate QMatrix acquisition method is required |
Define this symbol to indicate QMatrix acquisition method is required |
QT_NUM_CHANNELS |
The number of channels the library supports.( Possible values:4,8,16,32,56,64). Note: 56 channel for only ATxmega Devices. |
Value should be same as the number of channels that the library supports |
NUM_X_LINES |
The number of X lines the library supports.( Possible values:4,8) |
Value should be same as the number of X lines that the library supports. Refer to library selection guide |
NUM_Y_LINES |
The number of Y lines the library supports.( Possible values:1,2,4,7,8) Note: 7 Y-lines for only ATxmega Devices) |
Value should be same as the number of Y lines that the library supports. Refer to library selection guide |
_ROTOR_SLIDER_ |
Symbol defined if Rotor and/or slider is required |
Needs to be added in case user needs to configure ROTOR/SLIDER Needs to be removed for ALL KEYS configuration |
QT_MAX_NUM_ROTORS_SLIDERS |
Maximum number of rotors/sliders the library supports( possible values:0,2,4,8) |
Subject to support for rotors/sliders in the library selected. |
QT_DELAY_CYCLES |
Possible values :1,2,3,4,5,10,25,50 |
|
NUM_X_PORTS |
Number of ports on which the X lines needs to be spread. (Possible values 1,2,3) |
Maximum number of ports that the X lines can spread is 3. Note: Code memory required increases with the increase in NUM_X_PORTS |
PORT_X_1 |
First IO port for configuring the X lines.Any IO port available with the device. |
Drive electrode for touch sensing using QMatrix acquisition Valid when NUM_X_PORTS =1,2,3 |
PORT_NUM_1 |
1 |
Do not edit this macro Valid when NUM_X_PORTS =1,2,3 |
PORT_X_2 |
Second IO port for configuring the X lines. Any IO port available with the device. |
Drive electrode for touch sensing using QMatrix acquisition Valid when NUM_X_PORTS =2,3 |
PORT_NUM_2 |
2 |
Do not edit this macro Valid when NUM_X_PORTS =2,3 |
PORT_X_3 |
Third IO port for configuring the X lines. Any IO port available with the device. |
Drive electrode for touch sensing using QMatrix acquisition Valid when NUM_X_PORTS =3 |
PORT_NUM_3 |
3 |
Do not edit this macro Valid when NUM_X_PORTS =3 |
PORT_YA |
Any IO port available with the device. |
Receive electrode for touch sensing using QMatrix acquisition |
PORT_YB |
ADC port available for the device. |
Receive electrode for touch sensing using QMatrix acquisition |
PORT_SMP |
Any IO port available with the device. |
Port of the Sampling pin for touch sensing using QMatrix acquisition |
SMP_PIN |
Any IO port available with the device. |
Sampling pin for touch sensing using QMatrix acquisition |
_ATXMEGA_ |
Symbol defined if an ATxmega Device is used for QMatrix sensing technology |
Needs to be added if the device to be supported is ATxmegaxxxx |
SHARED_YAYB |
Possible values: 0 or 1 |
#define SHARED_YAYB 1 in case YA and YB are on same port else 0. |
Once you have selected the right library variant and configuration parameters for the application, follow the steps outlined below to integrate the library variant in your application.
Fill in the arrays x_line_info_t x_line_info[NUM_X_LINES] y_line_info_t ya_line_info[NUM_Y_LINES] and y_line_info_t yb_line_info[NUM_Y_LINES] using the pin configuration wizard provided by the QTouch Studio.
Copy the library variant that was selected in step one to your project’s working directory or update your project to point to the library selected.
Include the “touch_api.h” header file and assembler source file from the QTouch library in your application. The touch_api.h can be found in the release package at C:\Program Files\Atmel\Atmel_QTouch_Libraries_5.x\ Generic_QTouch_Libraries \AVR_Tiny_Mega_XMega\QMatrix\common_files. The assembler files mentioned below could be found at the location C:\Program Files\Atmel\Atmel_QTouch_Libraries_5.x\ Generic_QTouch_Libraries \AVR_Tiny_Mega_XMega\QMatrix\common_ files
qm_asm_tiny_mega.S in case of ATtiny and ATmega devices.
qm_asm_xmega.S in case of ATxmega devices.
qm_asm_m8535_m16.S in case of ATmega8535 and ATmega16 devices.
Initialize/create and use the touch api’s in your application
In your application, create, initialize and configure the sensors.
The APIs of interest are qt_enable_key/rotor/slider()
configure the global configuration parameters valid for all the sensors in the library
Provide timing for the QTouch libraries to operate. i,e. the QTouch libraries do not use any timer resources of the microcontroller. The Host application has to provide the required timing and also call the API’s at the appropriate intervals to perform touch sense detect operations
General application notes
The clock, host application and other peripherals needed by the host application needs to be initialized.
The QMatrix acquisition method libraries internally use TIMER1 for their operation.
Ensure that there are no conflicts between the resources used by the touch library and the host application
Ensure that the stack size is adjusted to factor in the stack depth required for the operation of the touch libraries.