Criteria |
Selection |
Notes |
---|---|---|
Microcontroller |
ATTiny88 |
List of supported devices can be found at Library_Selection_Guide.xls |
Number of channels required for the application |
6 |
number channels available for a Tiny88 is listed in Library_Selection_Guide.xls |
Number of X lines needed |
Based on the number of channels, since 8 channels is needed, 4 X lines are supported. NUM_X_LINES is 4 |
Since 3 X- lines (6 channels ) are used, Do not initialize 4th element in x_line_info[NUM_X_LINES]. Hence channel6, channel7 need not be used. |
Number of Y lines needed |
Based on the number of channels, since 8 channels is needed, 2 Y lines are supported |
NUM_Y_LINES is 2. |
Rotors and sliders required and Number of ROTOR/SLIDERS |
Yes - 2 |
Library variants supported for ATTiny88 is listed in the Library_Selection_Guide.xls |
X_LINES on pins as below(4-X lines) X0- B0, X1- D2,X3 – B7, X4 – B5 |
FILL_OUT_X_LINE_INFO(1,0), FILL_OUT_X_LINE_INFO(2,2), FILL_OUT_X_LINE_INFO(1,7), |
Main file has to be edited based on the configuration. This can be filled from the output of the pin configurator tool in QTouch Studio. |
Y_LINES on pins as below (2 Y-Lines) Y0A- D0, Y0B- C1, Y1A-D5, Y1B-C4, |
FILL_OUT_YA_LINE_INFO(0), FILL_OUT_YA_LINE_INFO(5), FILL_OUT_YB_LINE_INFO(1), FILL_OUT_YB_LINE_INFO(4), |
Main file has to be edited based on the configuration. Refer to section 5.8.2.1 Or This can be filled from the output of the pin configurator tool in QTouch Studio. Refer to section 5.8.2 |
NUM_X_PORTS |
2 |
Since X lines are spread on a multiple(2) ports: PORTB, PORTD |
Compiler tool chain |
IAR |
|
Choice of ports available for the design |
PORT_X_1 = B PORT_X_2 = D |
Any pins that are not conflicting with the host application and follow the configuration supported by library can be used. Or This can be filled from the output of the pin configurator tool in QTouch Studio. Refer to section 5.8.2 |
YA Line on PORTD |
||
YB Line on PORTC |
||
SMP Pin on PORTD pin 7 |
||
QT_DELAY_CYCLES of 4 |
||
Choice of Shared Ya and Yb on same port |
SHARED_YAYB |
This should be defined as 0 if YA and YB not shared on same port else 1 if shared on same port |
Given the above requirements for the applications, the first step is to select the right library variant required.
Step 1:
Select the Device that suits the requirements based on the touch sensing channels needed from the library selection guide available at C:\ Program Files\Atmel\ Atmel_QTouch_Libraries_5.x\ Library_Selection_Guide.xls
Step 2:
From the Library_selection_Guide.xls list, we see that there are a few variants of libraries supported for ATTiny device. Since the application requires 6 channels and rotor slider support, one has to select a library variant which supports at least 6 channels or more. Hence we select the 8 channel library which supports the required Port combination and the delay cycle preferred which works out to be the variant
libv1g1s1_8qm_4x_2y_krs_2rs.r90
Step 3:
Defining the constants / symbols in the project space or modifying in touch_config.h
In the host application file (say main.c), define the following constants and symbols
#define _QMATRIX_ #define QT_NUM_CHANNELS 8 #define NUM_X_LINES 4 #define NUM_Y_LINES 2 #define NUM_X_PORTS 2 #define PORT_X_1 B #define PORT_NUM_1 1 #define PORT_X_2 D #define PORT_NUM_2 2 #define PORT_YA D #define PORT_YB C #define PORT_SMP D #define SMP_PIN 7 #define QT_DELAY_CYCLES 4 #define ROTOR_SLIDER_ #define QT_MAX_NUM_ROTORS_SLIDERS 2 #define SHARED_YAYB 0
The above definitions are available in touch_config.h file. Alternatively, you can define these in your IDE's project options or have them defined in a separate header file.
Some of these macro’s can be taken from the output of the Pin configurator tool from QTouch Studio.
These can also be modified in the touch_config.h, after
defining the _QMATRIX_
in the project
space.
In case XMEGA device is used for QMatrix the symbol
__ATXMEGA__
has to be included in the
Project space along with the symbols mentioned above.
Step 4:
Filling Arrays in the main.c file
According to the pin availability for the touch sensing, initialize the arrays in the main.c file as below:
x_line_info_t x_line_info[NUM_X_LINES] = { FILL_OUT_X_LINE_INFO( 1,0u ), FILL_OUT_X_LINE_INFO( 2,2u ), FILL_OUT_X_LINE_INFO( 1,7u ), }; y_line_info_t ya_line_info[NUM_Y_LINES]= { FILL_OUT_YA_LINE_INFO( 0u ), FILL_OUT_YA_LINE_INFO( 5u ), }; y_line_info_t yb_line_info[NUM_Y_LINES] = { FILL_OUT_YB_LINE_INFO( 0u ), FILL_OUT_YB_LINE_INFO( 5u ), };
This part of the snippet can be taken from the output of the Pin configurator tool from QTouch Studio.
Step 5:
Usage of libraries
Now, you can use the touch API’s to create, initialize and perform touch sensing. These sample applications illustrate the usage of the API’s and the sequence of operation.