Atmel AT08774: SAM D20 PTC with I2C...
Transcript of Atmel AT08774: SAM D20 PTC with I2C...
-
Atmel QTouch
AT08774: SAM D20 PTC with I2C Slave
APPLICATION NOTE
Introduction
This application note explains the firmware solution implemented on Atmel
ATSAMD20J18 device using ARM Cortex-M0+ processor. The firmwaresolution demonstrates SAM D20 PTC self and mutual-capacitance sensormeasurements and transmit/receive touch data using I2C slave.
This implementation is useful in applications where the Host MCU need tocontrol various touch setup parameters over I2C. For instance, applicationsthat target low power consumption can adjust clock prescaler and scaninterval. Applications that target best noise performance can adjust noisecounter options dynamically.
The firmware solution is implemented using two SAM D20 Xplained Proboards, one acting as User board and the other for QDebug which streamstouch data to QTouch Analyzer.
The demonstration program is implemented in C and supports GCCCompiler used by Atmel Studio 7.
Features
Host MCU based touch parameter control I2C in slave mode Hardware Touch Acquisition using PTC Demonstration Program Uses I2C driver in ASF QTouch Composer generated touch project Utilizes SAM D20 Xplained Pro
Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
-
Table of Contents
Introduction......................................................................................................................1
Features.......................................................................................................................... 1
1. Abbreviations and Definitions.................................................................................... 4
2. Overview....................................................................................................................5
3. Hardware and Functional...........................................................................................63.1. Hardware Requisites.................................................................................................................... 63.2. Circuit Configuration.....................................................................................................................63.3. Test Setup.....................................................................................................................................73.4. Startup/Calibration Times............................................................................................................. 83.5. Calibration.................................................................................................................................... 83.6. Sleep............................................................................................................................................ 83.7. Touch Data Debug........................................................................................................................8
4. I2C Operation.......................................................................................................... 104.1. I2C-Compatible Address............................................................................................................ 104.2. CHANGE Pin..............................................................................................................................10
5. Firmware.................................................................................................................. 115.1. Application Flow..........................................................................................................................115.2. Creating Self/Mutual Combined Project......................................................................................115.3. Adding ASF Component (SERCOM I2C - Slave Mode Driver).................................................. 155.4. Configure and Process I2C........................................................................................................ 165.5. Files............................................................................................................................................175.6. Functions....................................................................................................................................18
6. Communication Protocol..........................................................................................216.1. Introduction.................................................................................................................................216.2. Address 0: Chip ID..................................................................................................................... 246.3. Address 1: Major/Minor Code Version........................................................................................246.4. Address 2: SelfCap Sensor Status.............................................................................................246.5. Address 3: MutualCap Sensor Status........................................................................................ 246.6. Address 4: Rotor/Slider Position.................................................................................................246.7. Address 6: Calibrate...................................................................................................................256.8. Address 7: Reset........................................................................................................................256.9. Address 8: Scan Interval............................................................................................................ 256.10. Address 10-11, 52-55: GAIN...................................................................................................... 256.11. Address 12, 64: Frequency Mode.............................................................................................. 266.12. Address 13-14, 65-68: PTC Prescaler........................................................................................266.13. Address 15-16, 69-72: Series Resistor...................................................................................... 276.14. Address 17-18, 73-76: PTC Prescaler CC Cal........................................................................276.15. Address 16, 60: Series Resistor CC Cal................................................................................. 276.16. Address 21-23, 81-83: Frequency Hops.................................................................................... 27
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
2
-
6.17. Address 24-25, 84-87: Filter Level............................................................................................. 286.18. Address 26-27, 88-91: Auto OS................................................................................................. 286.19. Address 28, 92: Auto Tune.........................................................................................................296.20. Address 29-30, 93: AKS.............................................................................................................296.21. Address 31-32, 94: Detect Threshold.........................................................................................306.22. Address 33-34, 95: Detect Hysteresis........................................................................................306.23. Address 35-36, 96: Position Resolution..................................................................................... 306.24. Address 97: Position Hysteresis.................................................................................................316.25. Address 37, 99: Detect Integration.............................................................................................316.26. Address 38, 100: Away From Touch Drift (Positive Drift)........................................................... 326.27. Address 39, 101: Towards Touch Drift (Negative Drift).............................................................. 326.28. Address 40, 102: Max On Duration............................................................................................ 336.29. Address 41, 103: Drift Hold Time............................................................................................... 336.30. Address 42, 104: Away from Touch Recalibration Delay............................................................336.31. Address 43, 105: Calibration Burst Count - Seq1...................................................................... 346.32. Address 44, 106: Calibration Burst Count - Seq2...................................................................... 346.33. Address 45, 107: Recalibration Threshold................................................................................. 346.34. Address 46-47,108-109: Sensor Post-processing Mode............................................................356.35. Address 48-49, 110-111: Auto OS Signal Stability Limit.............................................................356.36. Address 50-51,112-113: Frequency Auto Tune Stability Limit....................................................356.37. Address 52,114: Frequency Auto Tune In Counter.................................................................... 366.38. Address 54-55,116-117: Noise Measurement Signal Stability Limit .......................................... 366.39. Address 56,118: Noise Measurement Noise Limit......................................................................366.40. Address 57,119: Noise Measurement Sensor Lockout Setting.................................................. 376.41. Address 58,120: Noise Measurement Lockout Count Down......................................................376.42. Address 122 125: SelfCap Signal........................................................................................... 376.43. Address 126 129: SelfCap Reference.....................................................................................386.44. Address 130-137: MutualCap Signal..........................................................................................386.45. Address 138-145: MutualCap Reference................................................................................... 38
7. References.............................................................................................................. 40
8. Revision History.......................................................................................................41
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
3
-
1. Abbreviations and Definitions Acquisition cycle: A single capacitive measurement process ASF: Atmel Software Framework Calibration: Multiple touch measurements carried out continuously to set Reference Delta: Difference between Reference and Signal (Reference Signal) Detect Threshold: Determines delta required for a valid touch DGI: Data Gateway Interface EDBG: Embedded Debugger Drift: AdjustingReference level to track changes in signal level due to environmental changes I2C: Inter-Integrated Circuit Max on Duration: Duration for which sensor stays detected PTC: Peripheral Touch Controller Reference: Long term average measurement on a channel Recalibration Threshold: It is the level above which automatic recalibration occurs Scan Interval: Duration in which touch measurement is performed SCL: Serial Clock Line SDA: Serial Data Line SERCOM: Serial Communication Module Signal: Raw measurement for capacitance change on a channel X Line: The Sense Line connected to the X Electrode in Mutual capacitance method Y Line: The Sense Line connected to the Y Electrode used in Self-capacitance method
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
4
-
2. OverviewThe SAM D20 series device is a 32-bit ARM Cortex-M0+ based microcontroller, which supports hardwaretouch acquisition using PTC peripheral. PTC supports capacitive touch sensing on both self and mutualcapacitance sensors, without any external components (Series resistors might be required to handleextreme noise scenarios). Refer PTC User guide for detailed information on PTC and QTouch Library.
The firmware solution demonstrated in this application note uses two self-capacitance button sensors andone mutual capacitance slider sensor. This solution can be easily scaled to support various sensorconfiguration with appropriate modifications in firmware.
The device series provides up to six SERCOMs that can be configured to operate as an I2C, SPI, andUSART interface. The firmware solution configures SERCOM4 (PA12, PA13) of ATSAMD20J18 device asI2C communication interface in slave mode.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
5
http://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-Touch-Controller_User-Guide.pdf
-
3. Hardware and Functional
3.1. Hardware RequisitesThe following table lists the hardware required to build the test setup for analyzing this firmware solution.
Table 3-1.Hardware Requisites
Hardware Quantity
SAM D20 Xplained Pro board 2
QT1 QTouch Self-capacitance sensor board 1
QT1 QTouch Mutual capacitance sensor board 1
STK600 1
STK600 ATMEGA2560 board 1
3.2. Circuit ConfigurationThe following table shows connections used in this firmware solution.
Table 3-2.Sensor Pin Configuration used in SAM D20 User Board
SAM D20 Xplained Pro (User Board) QT1 Xplained Pro Sensor Board
PA02 (Y0) Self-capacitance Button_0 (Y_8)
PA03 (Y1) Self-capacitance Button_1 (Y_7)
PA10 (X2) Mutual capacitance Slider Channel_0 (X_1)
PA11 (X3) Mutual capacitance Slider Channel_1 (X_2)
PA20 (X8) Mutual capacitance Slider Channel_2 (X_3)
PA21 (X9) Mutual capacitance Slider Channel_3 (X_4)
PB06 (Y12) Mutual capacitance Slider (Y_S)
Note: The sense line (X / Y) numbers specified in table preceeding table under SAM D20 Xplained Proboard are as based on the information in the SAM D20 Datasheet. The X / Y numbers specified underQT1 sensor board are generic (as marked in QT1 sensor boards).
Table 3-3.Connection between SAM D20 User Board and AVR3009 Host Microcontroller
SAM D20 Xplained Pro (User Board) AVR3009 Host (ATmega2560)
PA12 (SDA) PD1
PA13 (SCL) PD0
PA27 (CHANGE pin) PD2
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
6
-
Table 3-4.Connection between SAM D20 User Board and SAM D20 Xplained Pro for QDebug
SAM D20 Xplained Pro (User Board) SAM D20 Xplained Pro (QDebug)
PA17 (SS) - Connect to GND -
PA18 (MOSI) PB22
PA16 (MISO) PB16
PA19 (SCK) PB23
GND GND
Figure 3-1.Circuit Configuration
The firmware solution provided is applicable for ATSAMD20J18 device operating as I2C Slave.
Firmware validation uses the demonstration code provided with the application note AVR3009: DrivingQTouch Device with IIC Interface with the required modifications.
An external pull-up resistor of 10k is required on CHANGE line and 4.7k is required on SCL and SDAlines. Using external pull-up resistor of 10k on RESET line is optional, as the device features an internalpull-up resistor on this pin.
3.3. Test SetupTable 3-2Sensor Pin Configuration used in SAM D20 User Board represents the actual test setup usedfor the firmware validation.
This setup uses one SAM D20 Xplained Pro board, which acts as user board and the same board is usedfor QDebug. This Xplained Pro board is directly connected to QT1 Mutual capacitance sensor board(slider sensor) and hooked wires for connecting to QT1 Self-capacitance sensor board (button sensor). Todemonstrate the firmware solution, the interconnection between Master and Slave uses wires as shown inthe following image:.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
7
http://www.atmel.com/products/touchsolutions/bsw/default.aspx?tab=documentshttp://www.atmel.com/products/touchsolutions/bsw/default.aspx?tab=documents
-
Figure 3-2.Test Setup
3.4. Startup/Calibration TimesThe device requires an initialization time of approximately 300ms. This includes calibration time of around200ms. Any subsequent recalibration will also take approximately 200ms.
The CHANGE line is asserted at startup, after initialization.
3.5. CalibrationThe calibration does not occur periodically. Keys are calibrated when one of the following conditionsoccur:
Power up Sensor signal value is greater than the Positive Recalibration Threshold
Default = 50% of Detect Threshold At the end of Max on Duration (if enabled)
Default = Disabled Host MCU issues a Calibrate Command
If any sensor was in detect state before recalibration, it will go out of detect after recalibration. This willchange the Status Bytes and trigger the CHANGE line to go low.
3.6. SleepThe default scan interval of the device is set as 20ms. In the firmware solution touch measurement isperformed on the configured sensors. To reduce power consumption, CPU sleeps during touchacquisition as well as for the remaining period of scan interval.
3.7. Touch Data DebugThe SAM D20 Xplained Pro contains Embedded Debugger (EDBG) that features an Atmel Data GatewayInterface (DGI) using SPI and I2C. The DGI can be used to transmit a variety of data from the XplainedPro kit to the host PC. This arrangement can be used to send QDebug data from a user board to PCrunning QTouch Analyzer for touch sensor data analysis and tuning. The example project generatedusing QTouch composer transfers QDebug data over SPI.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
8
-
To stream QDebug data from the user board (SAM D20 Xplained Pro) using another SAM D20 XplainedPro board, refer Table 3-4Connection between SAM D20 User Board and SAM D20 Xplained Pro forQDebug for connection details and refer to procedure provided in PTC User Guide.
The same user board SAM D20 Xplained Pro board can also be used to stream QDebug data for testingthe firmware solution provided. Required SPI debug line connections to EDBG is hard wired in SAM D20Xplained Pro board. So, using the corresponding debug related pin definitions in touch.h file as shownin the following table is sufficient to enable QDebug in the same Xplained Pro board.
Table 3-5.Using the Same SAM D20 (User Board) Xplained Pro for QDebug
SAM D20 Xplained Pro (User Board)
Pin Function
PB22 MOSI
PB16 MISO
PB23 SCK
PB31 SS
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
9
http://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-Touch-Controller_User-Guide.pdf
-
4. I2C OperationThe firmware solution use SERCOM I2C interface to communicate with Master MCU. This Atmel Two-wire Serial Interface is compatible with Philips I2C Bus/Protocol.
Refer to ATSAMD20J18 device datasheet for details of operation.
4.1. I2C-Compatible AddressThe I2C address for the slave ATSAMD20J18 device is set as 0x12.
4.2. CHANGE PinThe CHANGE pin is an active low open drain output that can be used to alert the host about any changein any of the sensor status, thus reducing the need for wasteful I2C communications. CHANGE pin goeslow when there is change in status bytes of any sensor or slider position values (Memory map address 2to 4, detailed in Table 6-1Memory Map). When the master performs a read from all the status bytes,CHANGE pin becomes high.
Poll rate: The host can make use of CHANGE pin output to initiate a communication; this will guaranteethe optimal polling rate.
If the host cannot make use of CHANGE pin, the poll rate should be no faster than once per acquisitioncycle. The default scan interval is 20ms. A faster scan interval will not provide new information and willslow down the chip operation.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
10
http://www.atmel.com/Images/Atmel-42129-SAM-D20_Datasheet.pdf
-
5. Firmware
5.1. Application Flow
5.2. Creating Self/Mutual Combined ProjectThe following procedure explains creating a combined project for both self and mutual capacitancesensors.
5.2.1. Create Self-capacitance ProjectUse QTouch Composer Project builder wizard and create self-capacitance project for two buttonsensors as per configuration in the following table, with QDebug enabled. This project name is referred asselfcap in the following sections.
Table 5-1.Self-capacitance Sensor Pin Configuration used in SAM D20 User Board
Parameter Sensepin
Gain Detectthreshold
Filterlevel
Autooversampling
Autotuning
Seriesresistor
Frequencymode
Button0 Y0(PA02)
1 30 8 Disable PRSC 100K None
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
11
-
Table 5-2.Debug Pin Configuration used in SAM D20 User Board
Parameter ATSAMD20J18 port pin
SPI_BB_SS PA17
SPI_BB_SCK PA19
SPI_BB_MOSI PA18
SPI_BB_MISO PA16
Y lines used in this project are custom configuration, based on available unused pins in the SAM D20Xplained Pro board. Note that the Y lines are not the same as used in standard ASF example projectSAM D20 Xplained Pro and QT1 Xplained Pro Self-capacitance example application.
5.2.2. Create Mutual capacitance ProjectUse QTouch Composer Project builder wizard and create mutual capacitance project for one slider sensoras per configuration in the following table, with QDebug disabled. This project name is referred asmutualcap in the following sections.
Table 5-3.Mutual Capacitance Sensor Pin Configuration used in SAM D20 User Board
Parameter X Line Y Line Gain Detectthreshold
Filterlevel
Autooversampling
Autotuning
Seriesresistor
Frequencymode
SliderChannel0
X2(PA10)
Y12(PB06)
1 30 8 Disable PRSC 100K None
SliderChannel1
X3(PA11)
Y12(PB06)
1
SliderChannel2
X8(PA20)
Y12(PB06)
1
SliderChannel3
X9(PA21)
Y12(PB06)
1
5.2.3. Create Combined (Self + Mutual capacitance) ProjectThe self-capacitance project created is set as base application project and the mutual capacitance projectcreated is used as reference. Append the required contents from mutual capacitance to self-capacitanceproject, for enabling touch measurement on both self and mutual capacitance sensors.
The following procedure details the steps to include required contents. Use the demonstration projectavailable for reference.
1. Copy all the macros (excluding DEF_TOUCH_PTC_ISR_LVL) from the touch.h file in themutualcap project and paste in the touch.h file from the selfcap project.
2. Compare both touch.c files, copy the required contents from the mutual capacitance project andperform the following changes in the selfcap base project.2.1. Declare the data block array for the mutual capacitance method, after the self-capacitance
data array declaration./** * Mutual Cap Data block provided as input to Touch library. */static uint8_t mutlcap_data_blk[PRIV_MUTLCAP_DATA_BLK_SIZE];
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
12
-
2.2. Declare mutual capacitance sensors pin information, along with the self-capacitancesensor details./** * Mutual Cap Sensor Pins Info. */uint16_t mutlcap_xy_nodes[DEF_MUTLCAP_NUM_CHANNELS * 2] = {DEF_MUTLCAP_NODES};filter_level_t mutlcap_filter_level_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_FILTER_LEVEL_PER_NODE};uint8_t mutlcap_auto_os_per_node[DEF_MUTLCAP_NUM_CHANNELS]= {DEF_MUTLCAP_AUTO_OS_PER_NODE};gain_t mutlcap_gain_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_GAIN_PER_NODE};rsel_val_t mutlcap_resistor_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_SENSE_RESISTOR_PER_NODE };prsc_div_sel_t mutlcap_prsc_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_CLK_PRESCALE_PER_NODE };prsc_div_sel_t mutlcap_boot_prsc_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_CC_CAL_CLK_PRESCALE_PER_NODE};rsel_val_t mutlcap_boot_resistor_per_node[DEF_MUTLCAP_NUM_CHANNELS] = {DEF_MUTLCAP_CC_CAL_SENSE_RESISTOR_PER_NODE};freq_hop_sel_t mutlcap_freq_hops[3u] = {DEF_MUTLCAP_HOP_FREQS};
2.3. Define Configuration structure for mutual capacitance after self-capacitance structure.2.4. Update the touch_config structure with the address of mutual capacitance configuration
parameter, as shown in following code snippet.touch_config_t touch_config = { &mutlcap_config, &selfcap_config, /* Pointer to Self Cap configuration structure.*/DEF_TOUCH_PTC_ISR_LVL, /* PTC interrupt level. */};
2.5. Define the measure complete callback prototype, after self cap measure complete callbackroutine.void touch_mutlcap_measure_complete_callback( void );
2.6. Similar to measure complete callback function for self-capacitance, define the mutualcapacitance measure complete call back function in the end of touch.c file.
3. To invoke the mutual capacitance measurement related APIs as follows. Use the mutualcapacitance project touch.c file as reference.3.1. Invoke touch_mutlcap_sensors_init API after invoking
touch_selfcap_sensors_init.touch_ret = touch_mutlcap_sensors_init(&touch_config); if (touch_ret != TOUCH_SUCCESS) { touch_app_err_handler(TOUCH_INIT_CONFIG_ERR, touch_ret); }
3.2. Similarly invoke touch_mutlcap_sensors_calibrate after invokingtouch_selfcap_sensors_calibrate. touch_ret = touch_mutlcap_sensors_calibrate(DEF_MUTL_AUTO_TUNE_VALUE); if (touch_ret != TOUCH_SUCCESS) { touch_app_err_handler(TOUCH_INIT_CALIB_ERR, touch_ret); } return (touch_ret);
3.3. Next, configure the mutual capacitance sensors in the touch_sensors_config routinedefinition. Append the mutual capacitance sensor configuration next to the self-capacitancesensors.touch_ret_t touch_sensors_config(void){ touch_ret_t touch_ret = TOUCH_SUCCESS; sensor_id_t sensor_id;
touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY,
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
13
-
CHANNEL_0,CHANNEL_0, NO_AKS_GROUP, 15u, HYST_25,RES_8_BIT, &sensor_id); if (touch_ret != TOUCH_SUCCESS) { touch_app_err_handler(TOUCH_SENSOR_CONFIG_ERR, touch_ret); }
touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_1,CHANNEL_1, NO_AKS_GROUP, 15u, HYST_25,RES_8_BIT, &sensor_id); if (touch_ret != TOUCH_SUCCESS) { touch_app_err_handler(TOUCH_SENSOR_CONFIG_ERR, touch_ret); }
touch_ret = touch_mutlcap_sensor_config(SENSOR_TYPE_SLIDER, CHANNEL_0,CHANNEL_3, NO_AKS_GROUP, 10u, HYST_25,RES_8_BIT, 0u, &sensor_id); if (touch_ret != TOUCH_SUCCESS) { touch_app_err_handler(TOUCH_SENSOR_CONFIG_ERR, touch_ret); }
return (touch_ret);}
3.4. Finally, invoke the mutual capacitance sensor measure routine next to the self-capacitancesensor measure routine. The touch acquisition process is sequential in case of SAM D20PTC. So, before invoking the mutual capacitance sensor acquisition, the application needsto ensure that the acquisition is complete on the self-capacitance sensors and vice-versa.The following code snippet shows the conditional implementation required for invokingtouch acquisition.
touch_ret_t touch_sensors_measure(void){ touch_ret_t touch_ret = TOUCH_SUCCESS; if (!(p_selfcap_measure_data->acq_status & TOUCH_CC_CALIB_ERROR)) {
if (touch_time.time_to_measure_touch == 1u) { if(start_check == 1 || p_mutlcap_measure_data->measurement_done_touch == 1u) { touch_ret = touch_selfcap_sensors_measure( touch_time.current_time_ms, NORMAL_ACQ_MODE, touch_selfcap_measure_complete_callback);
if ((touch_ret != TOUCH_ACQ_INCOMPLETE) && (touch_ret == TOUCH_SUCCESS)) { p_mutlcap_measure_data->measurement_done_touch = 0u; start_check = 0; } else if ((touch_ret != TOUCH_SUCCESS) && (touch_ret != TOUCH_ACQ_INCOMPLETE)) { touch_app_err_handler(TOUCH_MEASURE_INCOMPLETE, touch_ret); /* Reaching this point can be due to - * 1. The api has retured an error due to a invalid * input parameter. * 2. The api has been called during a invalid Touch * Library state. */ } } } if(p_selfcap_measure_data->measurement_done_touch == 1u) { touch_ret = touch_mutlcap_sensors_measure( touch_time.current_time_ms, NORMAL_ACQ_MODE, touch_mutlcap_measure_complete_callback);
if ((touch_ret != TOUCH_ACQ_INCOMPLETE) && (touch_ret == TOUCH_SUCCESS)) { p_selfcap_measure_data->measurement_done_touch = 0u; touch_time.time_to_measure_touch = 0u; } else if ((touch_ret != TOUCH_SUCCESS) && (touch_ret != TOUCH_ACQ_INCOMPLETE)) {
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
14
-
touch_app_err_handler(TOUCH_MEASURE_INCOMPLETE, touch_ret); /* Reaching this point can be due to - * 1. The api has retured an error due to a invalid * input parameter. * 2. The api has been called during a invalid Touch * Library state. */ } } } else { /* To find which sensor failed in the calibration, check p_xxxxcap_measure_data->p_sensors[].state == SENSOR_CALIBRATION_ERROR */ touch_app_err_handler(TOUCH_MEASURE_CC_CAL_FAILED, touch_ret); }
return (touch_ret);}
Note: In the above code, the start_check variable is used to invoke touch acquisition atpower up. This should be initialized to "1" in touch.c file (uint8_t start_check =1u;).
Build and Test:The project creation, which can perform measurement on both self and mutualcapacitance sensors is complete. Build the project at this stage and ensure there are no errors /warnings. Then download it into the ATSAMD20J18 device in SAM D20 Xplained Pro user board.
QDebug:The combined project has QDebug enabled for self-capacitance sensors. So, the performanceof self-capacitance sensors can be analyzed using QTouch Analyzer.
To enable QDebug for the mutual capacitance sensor, enable the required macro definition in thetouch.h file as follows.//#define DEF_TOUCH_QDEBUG_ENABLE_SELFCAP#define DEF_TOUCH_QDEBUG_ENABLE_MUTLCAP #define DEF_TOUCH_QDEBUG_ENABLE 1u
Build and load the project again. Now, mutual capacitance slider performance can be analyzed in QTouchAnalyzer.Note: The QTouch Analyzer can only provide either self or mutual capacitance sensor data,simultaneously.
5.3. Adding ASF Component (SERCOM I2C - Slave Mode Driver)Next step is to add SERCOM I2C Slave Mode Callback driver from ASF, into the combined projectcreated. To open the ASF wizard in the project, click on ASF -> ASF Wizard. Then search and selectSERCOM I2C Slave Mode I2C driver (Callback) under the Available Modules. Click on the Addbutton as shown in the following figure.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
15
-
Figure 5-1.Selecting SERCOM I2C Slave Driver from ASF
The SERCOM I2C driver is available under the Selected Modules list. Click on the Apply button toinclude the selected I2C diver module into the combined project. Save the changes and perform a testbuild using the project.Figure 5-2.Adding SERCOM I2C Slave Driver into the Project
5.4. Configure and Process I2CIn the user project (combined project created) which includes required I2C drivers from ASF, I2C shouldbe configured in slave mode and the necessary callbacks should be defined.
The I2C driver added from ASF does not handle internal memory addressing. So the application codeneeds to process the read and write commands appropriately.
In the user project, include the source and header files available in the apps_src folder in thedemonstration project. Among the included source files, i2c_process.c file takes care of configuringthe I2C in slave mode and define I2C callbacks for read request, write request, read complete, writecomplete operations.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
16
-
As well, this file handles internal memory addressing to comply with master requests. This internaladdressing implementation requires number of bytes written by master to the slave device. So, in thei2c_slave_interrupt.c file in the interrupt handler _i2c_slave_interrupt_handler definition,a variable for number of bytes written is incremented whenever request is received for write, as shown infollowing code snippet./* Continue buffer write/read */ } else if (module->buffer_length > 0 && module->buffer_remaining > 0) { /* Call function based on transfer direction */ if (module->transfer_direction == I2C_TRANSFER_WRITE) { _i2c_slave_read(module); num_bytes_written++; } else { _i2c_slave_write(module);
The variable num_bytes_written should be declared as extern in the i2c_slave_interrupt.cfile.extern uint8_t num_bytes_written;
Based on the number of bytes written, the slave decides whether it is a master write instruction or readinstruction.
Case 1: If the number of bytes written is one, then slave determines this as a read request from master.The data byte received is considered as address to be read and the slave points to that address for readoperation.
Case 2: If the number of bytes written is more than one, then slave determines this as a write requestfrom master. Slave writes the received data bytes into a data buffer.
Process received data:
During write operation, data bytes written are stored in a data buffer. This data must be processedappropriately, where the first byte in buffer represents the address to be written into and the followingbytes are the data bytes to be written. These data bytes written updates / configures the touch setupparameters, discussed in following sections. The i2c_process.c file also handles processing of thereceived data bytes and updating the memory map.
To complete configuring and data processing, replace the main.c file available in demonstration projectin the user project. This completes the demonstration project creation by the user.
Build the project and test it using any I2C Master MCU.
5.5. FilesThe folder structure of the firmware solution is as follows:
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
17
-
Figure 5-3.Folder Structure
The following table provides a brief description of additional files used in this firmware solution.Table 5-4.File Description
File name Description
configuration.h Configuration for Change pin is provided here.memorymap.h Defines memory map structure which contains touch setup parameters as objects.memorymap.c Provides a default value to the touch setup parameters in memory map.i2c_process.h It consist of function prototypes and macro definitions used in i2c_process.ci2c_process.c It configures I2C and processes data bytes received.
5.6. FunctionsA brief description of functions used in the additional files included in the firmware solution are provided inthe following table.Table 5-5.Functions
Function Description
void memorymap_defaults(void) Provides default values totouch setup parameters inmemory map.
Input None
Output None
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
18
-
Function Description
void i2c_read_request_callback(structi2c_slave_module *const module)
This function points theread location to theappropriate memory maplocation requested bymaster.
Input *const pointerto the I2C slavemodulestructure.
Output None
void i2c_write_request_callback(structi2c_slave_module *const module)
This function points thewrite location to the writebuffer.
Input *const pointerto the I2C slavemodulestructure.
Output None
void i2c_read_complete_callback(structi2c_slave_module *const module)
Updates the change pinstatus when the statusbytes is read by master.
Input *const pointerto the I2C slavemodulestructure.
Output None
void i2c_write_complete_callback(structi2c_slave_module *const module)
Checks the number ofbytes written and takesnecessary action for read/write request.
Input *const pointerto the I2C slavemodulestructure.
Output None
void configure_i2c_slave(void) Configures SERCOM4I2C in Slave mode.
Input None
Output None
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
19
-
Function Description
void configure_i2c_slave_callbacks(void) Register and enable I2CSlave callback routines.
Input None
Output None
void update_sensor_data(void) Updates touch sensordata measured in thememory map structureand updates change pinstatus based on sensorstate.
Input type - type codefor the objectdetailsrequested
Output None
void update_setup_config(void) Updates touch setupparameters based ondata written by master.
Input None
Output None
void update_memory_map(void) Updates the memory mapwith data written bymaster.
Input None
Output None
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
20
-
6. Communication Protocol
6.1. IntroductionThe device is address mapped. All communications consist of write and read access to the locations in an8-bit address map.
The memory map structure that contains the touch status / setup parameters used in firmware solutionare provided in the following table. The touch setup parameters can be modified as required for the userapplication.
Table 6-1.Memory Map
Address Use Access
0 Chip ID Read
1 Major/Minor Code Version Read
2 SelfCap Sensor Status Read
3 MutualCap Sensor Status Read
4 Rotor/Slider Position Read
5 Reserved_1 Read
6 Calibrate Read/Write
7 Reset Read/Write
8 Scan Interval Read/Write
9 Reserved_2 Read/Write
Self-capacitance Setup Block
10 Gain for Button_0 Read/Write
11 Gain for Button_1 Read/Write
12 Frequency_Mode Read/Write
13 PTC Prescaler for Channel_0 Read/Write
14 PTC Prescaler for Channel_1 Read/Write
15 Series Resistor for Channel_0 Read/Write
16 Series Resistor for Channel_1 Read/Write
17 PTC Prescaler - CC Cal for Channel_0 Read/Write
18 PTC Prescaler - CC Cal for Channel_1 Read/Write
19 Series Resistor - CC Cal for Channel_0 Read/Write
20 Series Resistor - CC Cal for Channel_1 Read/Write
21 23 Frequency Hops Read/Write
24 Filter Level for Channel_0 Read/Write
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
21
-
Address Use Access
25 Filter Level for Channel_1
26 Auto OS for Channel_0 Read/Write
27 Auto OS for Channel_1
28 Auto Tune Read/Write
29 30 AKS (Key 0 1) Read/Write
31 32 Detect Threshold (Button 0 1) Read/Write
33 34 Detect Hysteresis (Button 0 1) Read/Write
35 36 Position Resolution (Button 0 1) Read/Write
37 Detect Integration Read/Write
38 Away From Touch Drift Read/Write
39 Towards Touch Drift Read/Write
40 Max On Duration Read/Write
41 Drift Hold Time Read/Write
42 Away from touch Recalibration Delay Read/Write
43 Calibration burst count - Seq1 Read/Write
44 Calibration burst count Seq2 Read/Write
45 Recalibration Threshold Read/Write
46 47 Sensor post-processing mode Read/Write
48 49 Auto OS signal stability limit
50 51 Frequency auto tune stability limit Read/Write
52 Frequency auto tune In counter Read/Write
53 Reserved_3 Read/Write
54 55 Noise measurement signal stability limit Read/Write
56 Noise measurement noise limit Read/Write
57 Noise measurement sensor lockout setting Read/Write
58 Noise measurement lockout count down Read/Write
59 Reserved_4 Read/Write
Mutual capacitance Setup Block
60 Gain for Slider Channel_0 Read/Write
61 Gain for Slider Channel_1 Read/Write
62 Gain for Slider Channel_2 Read/Write
63 Gain for Slider Channel_3 Read/Write
64 Frequency_Mode Read/Write
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
22
-
Address Use Access
65 68 PTC Prescaler (Channel_0 to Channel_3) Read/Write
69 72 Series Resistor (Channel_0 to Channel_3) Read/Write
73 76 PTC Prescaler - CC Cal (Channel_0 to Channel_3)
77 80 Series Resistor - CC Cal (Channel_0 to Channel_3) Read/Write
81 83 Frequency Hops Read/Write
84 87 Filter Level (Channel_0 to Channel_3) Read/Write
88 91 Auto OS (Channel_0 to Channel_3) Read/Write
92 Auto Tune Read/Write
93 Slider AKS Read/Write
94 Slider Detect Threshold Read/Write
95 Slider Detect Hysteresis Read/Write
96 Slider Position Resolution Read/Write
97 Slider Position Hysteresis Read/Write
98 Reserved_5 Read/Write
99 Detect Integration Read/Write
100 Away From Touch Drift Read/Write
101 Towards Touch Drift Read/Write
102 Max On Duration Read/Write
103 Drift Hold Time Read/Write
104 Away from touch Recalibration Delay Read/Write
105 Calibration burst count - Seq1 Read/Write
106 Calibration burst count Seq2 Read/Write
107 Recalibration Threshold Read/Write
108 109 Sensor post-processing mode Read/Write
110 111 Auto OS signal stability limit Read/Write
112 113 Frequency auto tune stability limit Read/Write
114 Frequency auto tune In counter Read/Write
115 Reserved_6 Read/Write
116 117 Noise measurement signal stability limit Read/Write
118 Noise measurement noise limit Read/Write
119 Noise measurement sensor lockout setting Read/Write
120 Noise measurement lockout count down Read/Write
121 Reserved_7 Read
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
23
-
Address Use Access
122 125 SelfCap Signal Read
126 129 SelfCap Reference Read
130 137 MutualCap Signal Read
138 145 MutualCap Reference Read
6.2. Address 0: Chip ID
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0 Chip ID
This address holds the Chip ID, always reads 0x1A.
6.3. Address 1: Major/Minor Code Version
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 Major Version Minor Version
There is an 8-bit major and minor version of the firmware revision. The top nibble of the firmware versionregister contains the major version (1.0) and the bottom nibble contains the minor version (1.0).
6.4. Address 2: SelfCap Sensor Status
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
2 0 0 0 0 0 0 Button_1 Button_0
The last two bits indicate touch status of two self-capacitance buttons. It is reported as 1 if button istouched else reports 0 when untouched. A change in this status bits causes CHANGE line to assert low.
6.5. Address 3: MutualCap Sensor Status
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
3 0 0 0 0 0 0 0 Slider_State
The last bit indicates touch status of mutual capacitance slider. It is reported as 1 if slider is touched elsereports 0 when slider is not in detection. A change in this status bit causes CHANGE line to assert low.
6.6. Address 4: Rotor/Slider Position
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
4 Slider Position
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
24
-
This byte reports slider position output. This is valid only when slider is in detect state. A change in thisvalue causes CHANGE line to assert low.
6.7. Address 6: Calibrate
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
6 CALIBRATE
Writing any non-zero value into this address will trigger the device to start a recalibration on all enabledsensors.
6.8. Address 7: Reset
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
7 RESET
Any non-zero value will trigger the device to reset. After reset, the device will revert to default settingsprovided to touch setup parameters.
The host must wait for at least 300ms for the operation to be completed before communications can bere-established.
6.9. Address 8: Scan Interval
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
8 SCAN INTERVAL
This 8-bit value represents the duration (in ms) to invoke touch measurement. Longer the interval yieldslower power consumption, as the device sleeps longer after touch measurement, but at the cost of slowerresponse to touch.
6.10. Address 10-11, 52-55: GAIN
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
10 GAIN for SelfCap Button_0
11 GAIN for SelfCap Button_1
52 GAIN for MutualCap Slider Channel _0
53 GAIN for MutualCap Slider Channel _1
54 GAIN for MutualCap Slider Channel _2
55 GAIN for MutualCap Slider Channel _3
Address 10-11 represents gain setting for self-capacitance buttons.
Address 52-55 represents gain setting for mutual capacitance slider channels.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
25
-
Gain setting is applied on a per-channel basis to allow scaling-up of the touch delta upon contact. Gainsetting depends on the sensor design and touch panel thickness.
Range: GAIN_1 to GAIN_32Default: GAIN_1 ( Self-capacitance), GAIN_2 (Mutual capacitance)
6.11. Address 12, 64: Frequency Mode
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
12 Frequency Mode for SelfCap
56 Frequency Mode for MutualCap
Address 12 represents frequency mode to be used for self-capacitance buttons.
Address 56 represents frequency mode to be used for mutual capacitance slider.
Frequency mode setting allows users to tune the PTC touch acquisition frequency characteristics tocounter environment noise. The different frequency modes available are:
FREQ_MODE_HOP FREQ_MODE_SPREAD FREQ_MODE_SPREAD_MEDIAN FREQ_MODE_NONE
Refer to PTC User guide for more details.
Default: FREQ_MODE_NONE (For both Self-capacitance and Mutual capacitance).
6.12. Address 13-14, 65-68: PTC Prescaler
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
13 16 PTC Prescaler for SelfCap
65 68 PTC Prescaler for MutualCap
This setting controls the clock pre-scaler to the Generic clock input to PTC. The Generic clock input toPTC should be set to 4MHz. The pre-scaler setting scales down the PTC clock as follows:
PRSC_DIV_SEL_1 sets PTC Clock to 4MHz PRSC_DIV_SEL_2 sets PTC Clock to 2MHz PRSC_DIV_SEL_4 sets PTC Clock to 1MHz PRSC_DIV_SEL_8 sets PTC Clock to 500kHz
Range: PRSC_DIV_SEL_1 to PRSC_DIV_SEL_8Default: PRSC_DIV_SEL_1 (For both Self-capacitance and Mutual capacitance)
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
26
http://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-Touch-Controller_User-Guide.pdf
-
6.13. Address 15-16, 69-72: Series Resistor
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
15 16 Series Resistor for SelfCap
77 80 Series Resistor for MutualCap
This setting controls the value of internal series resistor on the Y line. RSEL_VAL_0 sets internal series resistor to 0 RSEL_VAL_20 sets internal series resistor to 20k RSEL_VAL_50 sets internal series resistor to 50k RSEL_VAL_100 sets internal series resistor to 100k
Range: RSEL_VAL_0 to RSEL_VAL_100Default: RSEL_VAL_100 (For both Self-capacitance and Mutual capacitance)
6.14. Address 17-18, 73-76: PTC Prescaler CC Cal
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
17 18 CC Cal PTC Prescaler for SelfCap
73 76 CC Cal PTC Prescaler for MutualCap
This setting controls PTC Prescaler to be used during compensation capacitor calibration.
6.15. Address 16, 60: Series Resistor CC Cal
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
16 CC Cal Series Resistor for SelfCap
60 CC Cal Series Resistor for MutualCap
This setting controls Series Resistor to be used during compensation capacitor calibration.
6.16. Address 21-23, 81-83: Frequency Hops
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
21 Frequency Hop_1 for SelfCap
22 Frequency Hop_2 for SelfCap
23 Frequency Hop_3 for SelfCap
81 Frequency Hop_1 for MutualCap
82 Frequency Hop_2 for MutualCap
83 Frequency Hop_3 for MutualCap
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
27
-
This frequency hop delay setting is used when the Frequency mode is set to FREQ_MODE_HOP.A set of three frequency hop delay settings should be specified. This delay setting inserts n PTC clockcycles between consecutive measurements on a given sensor, thereby changing the PTC acquisitionfrequency.
FREQ_HOP_SEL_1 setting inserts 1 PTC clock cycle between consecutive measurements.FREQ_HOP_SEL_15 setting inserts 15 PTC clock cycles.Higher delay setting will increase the total time taken for capacitance measurement on a given sensor ascompared to a lower delay setting. A desired setting can be used to avoid noise around the samefrequency as the acquisition frequency.
Range:FREQ_HOP_SEL_1 to FREQ_HOP_SEL_16
6.17. Address 24-25, 84-87: Filter Level
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
24-25 Filter Level for SelfCap
84 87 Filter Level for MutualCap
This filter level setting controls the number of samples taken to resolve each acquisition. A higher filterlevel setting provides improved signal to noise ratio under noisy conditions, while increasing the total timefor measurement resulting in increased power consumption and response time.
Range: FILTER_LEVEL_1 to FILTER_LEVEL_64Default: FILTER_LEVEL_8 (For both Self-capacitance and Mutual capacitance)
6.18. Address 26-27, 88-91: Auto OS
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
26 27 Auto OS for SelfCap
88 91 Auto OS for MutualCap
Auto oversample controls the automatic oversampling of sensor channels when unstable signals aredetected with the default setting of 'Filter level'.
Enabling Auto oversample results in 'Filter level' x 'Auto Oversample' number of samples taken on thecorresponding sensor channel when an unstable signal is observed. In a case where 'Filter level' is set toFILTER_LEVEL_4 and 'Auto Oversample' is set to AUTO_OS_4, 4 oversamples are taken with stablesignal values and 16 oversamples are taken when unstable signal is detected.
Range: AUTO_OS_DISABLE to AUTO_OS_128Default: AUTO_OS_DISABLE (For both Self-capacitance and Mutual capacitance)
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
28
-
6.19. Address 28, 92: Auto Tune
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
22 Auto Tune for SelfCap
66 Auto Tune for MutualCap
Auto tune parameter setting is passed to the touch_xx_sensors_calibrate API in order to allowusers to tune the PTC module for power consumption or noise performance.
AUTO_TUNE_PRSC
When Auto tuning of pre-scaler is selected the PTC uses the user defined internal series resistor setting(DEF_MUTLCAP_SENSE_RESISTOR) and the pre-scaler is adjusted to slow down the PTC operation toensure full charge transfer. Auto tuning of pre-scaler with RSEL_VAL_100 as the series resistor results inbest noise performance while resulting in increased power consumption and touch response time.
AUTO_TUNE_RSEL
When Auto tuning of the series resistor is selected the PTC runs at user defined pre-scaler setting speed(DEF_MUTLCAP_CLK_PRESCALE) and the internal series resistor is tuned automatically to the optimumvalue to allow for full charge transfer. Auto tuning of series resistor with PRSC_DIV_SEL_1 as the PTCpre-scale results in best case power consumption.
AUTO_TUNE_NONE
When manual tuning option is selected, the user defined values of PTC pre-scaler and series resistor isused for PTC operation as given in DEF_MUTLCAP_CLK_PRESCALE andDEF_MUTLCAP_SENSE_RESISTOR.Default: AUTO_TUNE_PRSC (For both Self-capacitance and Mutual capacitance)
6.20. Address 29-30, 93: AKS
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
29 AKS for SelfCap Button_0
30 AKS for SelfCap Button_1
93 AKS for MutualCap Slider
In designs, where the sensors are close together or configured for high sensitivity, multiple sensors mightreport a detect simultaneously. To allow applications to determine the intended single touch, the touchlibrary provides the user the ability to configure a certain number of sensors in an AKS group.
When a group of sensors are in the same AKS group, only the first strongest sensor will report detection.The sensor reporting detection will continue to report detection even if another sensor's delta becomesstronger. The sensor stays in detect until its delta falls below its detection threshold. If any more sensorsin the AKS group are still in detect only the strongest will report detection. At a given time point, only onesensor from each AKS group is reported to be in detect.
Range: NO_AKS_GROUP to AKS_GROUP_7Default: NO_AKS_GROUP (For all Self and Mutual capacitance sensors)
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
29
-
6.21. Address 31-32, 94: Detect Threshold
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
31 Detect Threshold for SelfCap Button_0
32 Detect Threshold for SelfCap Button_1
94 Detect Threshold for MutualCap Slider
A sensors detect threshold define the quantity the signal must increase above its reference level toqualify as a potential touch detect. However, the final detection confirmation must satisfy the DetectIntegrator (DI) limit. Larger threshold values desensitize sensors since the signal must change more (i.e.requires larger touch) to exceed the threshold level. Conversely, lower threshold levels make sensorsmore sensitive.
Threshold setting depends on the amount of signal swing when a sensor is touched. Usually, thicker frontpanels or smaller electrodes have smaller signal swing on touch, thus require lower threshold levels.
Range: 3 to 255
Default: 20 (Self-capacitance), 30 (Mutual capacitance)
6.22. Address 33-34, 95: Detect Hysteresis
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
33 Detect Hysteresis for SelfCap Button_0
34 Detect Hysteresis for SelfCap Button_1
95 Detect Hysteresis for MutualCap Slider
This setting is sensor detection hysteresis value. It is expressed as a percentage of the sensor detectionthreshold setting. When a sensor goes into detect its threshold level is reduced (by the hysteresis value)in order to avoid the sensor dither in and out of detect if the signal level is close to original threshold level.
Setting of 0 = 50% of detect threshold value (HYST_50) Setting of 1 = 25% of detect threshold value (HYST_25) Setting of 2 = 12.5% of detect threshold value (HYST_12_5) Setting of 3 = 6.25% of detect threshold value (HYST_6_25)
Range: HYST_6_25 to HYST_50Default: HYST_25 (For all Self and Mutual capacitance sensors)
6.23. Address 35-36, 96: Position Resolution
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
35 Position Resolution for SelfCap Button_0
36 Position Resolution for SelfCap Button_1
96 Position Resolution for MutualCap Slider
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
30
-
The rotor or slider needs the position resolution (angle resolution in case of rotor and linear resolution incase of slider) to be set. Resolution is the number of bits needed to report the position of rotor or slider.
Range: 2 bits to 8 bits
Default: 8bits (For all Self and Mutual capacitance sensors)
6.24. Address 97: Position Hysteresis
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
97 Position Hysteresis for MutualCap Slider
In case of Mutual Cap, the rotor or slider needs the position hysteresis (angle hysteresis in case of rotorand linear hysteresis in case of slider) to be set. It is the number of positions the user has to move back,before touch position is reported when the direction of scrolling is changed and during the first scrollingafter user press.
Hysteresis can range from 0 (1 position) to 7 (8 positions). The hysteresis is carried out at 8 bitsresolution internally and scaled to desired resolution; therefore at resolutions lower than 8 bits there mightbe a difference of 1 reported position from the hysteresis setting, depending on where the touch isdetected.
Position hysteresis is not used in case of self-capacitance method sensors.
Range: 0 to 7
Default: 0 (For Mutual capacitance Slider)
6.25. Address 37, 99: Detect Integration
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
37 Detect Integration for SelfCap
99 Detect Integration for MutualCap
The QTouch Library features a detect integration mechanism, which confirm detection in a robustenvironment. The detect integration (DI) acts as a simple signal filter to suppress false detections causedby spurious events such as electrical noise.
A counter is incremented each time the sensor delta has exceeded its threshold and stayed there for aspecific number of acquisitions, without going below the threshold levels. When this counter reaches apreset limit (the DI value) the sensor is finally declared to be touched. If on any acquisition the deltaexceeds the threshold level, the counter is cleared and the process has to start from the beginning. TheDI process is applicable to a 'release' (going out of detect) event as well.
For example, if the DI value is 10, the device has to exceed its threshold and stay there for 10 successiveacquisitions without going below the threshold level, before the sensor is declared to be touched.
Range: 0 to 255
Default: 4
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
31
-
6.26. Address 38, 100: Away From Touch Drift (Positive Drift)
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
38 Away From Touch Drift for SelfCap
100 Away From Touch Drift for MutualCap
6.27. Address 39, 101: Towards Touch Drift (Negative Drift)
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
39 Towards Touch Drift for SelfCap
101 Towards Touch Drift for MutualCap
Drift in a general sense means adjusting reference level (of a sensor) to allow compensation fortemperature (or other factor) effect on physical sensor characteristics. Decreasing reference level forsuch compensation is called Negative drift and increasing reference level is called Positive drift.Specifically, the drift compensation should be set to compensate faster for increasing signals than fordecreasing signals.
Signals can drift because of changes in physical sensor characteristics over time and temperature. It iscrucial that such drift be compensated for; otherwise false detections and sensitivity shifts can occur. Driftcompensation occurs only while there is no detection in effect. Once a finger is sensed, the driftcompensation mechanism ceases since the signal is legitimately detecting an object. Drift compensationworks only when the signal in question has not crossed the 'Detect threshold' level.
The drift compensation mechanism can be asymmetric; it can be made to occur in one direction fasterthan it does in the other simply by changing the appropriate setup parameters. Signal values of a sensortend to increase when an object (touch) is approaching it or a characteristic change of sensor over timeand temperature. Increasing signals should not be compensated quickly, as an approaching finger couldbe compensated for partially or entirely before even touching the channel (towards touch drift).
However, an object over the channel which does not cause detection, and for which the sensor hasalready made full allowance (over some period of time), could suddenly be removed leaving the sensorwith an artificially suppressed reference level and thus become insensitive to touch. In the latter case, thesensor should compensate for the object's removal by raising the reference level relatively quickly (awayfrom touch drift).
Away from Touch Drift Range: 0 to 127
Default: 5
Towards Touch Drift Range: 0 to 127
Default: 20
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
32
-
6.28. Address 40, 102: Max On Duration
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
40 Max On Duration for SelfCap
102 Max On Duration for MutualCap
The Maximum ON duration timer monitors such detections; if detection exceeds the timer's settings, thesensor is automatically recalibrated. After a recalibration has taken place, the affected sensor once againfunctions normally even if it still in contact with the foreign object.
Max on duration can be disabled by setting it to zero (infinite timeout) in which case the channel neverrecalibrates during a continuous detection (but the host could still command it).
Range: 0 to 255
Default: 0
6.29. Address 41, 103: Drift Hold Time
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
41 Drift Hold Time for SelfCap
103 Drift Hold Time for MutualCap
Drift Hold Time (DHT) is used to restrict drift on all sensors while one or more sensors are activated. Itdefines the length of time the drift is halted after a key detection. This feature is useful in cases of highdensity keypads where touching a key or floating a finger over the keypad would cause untouched keysto drift, and therefore create a sensitivity shift, and ultimately inhibit any touch detection.
Range: 1 to 255
Default: 20
6.30. Address 42, 104: Away from Touch Recalibration Delay
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
36 Away from Touch Recalibration Delay for SelfCap
78 Away from Touch Recalibration Delay for MutualCap
If any key is found to have a significant negative delta, it is deemed to be an error condition. If thiscondition persists beyond away from touch recalibration delay period, then an automatic recalibration iscarried out.
A counter is incremented each time the sensor delta is equal to the away from touch recalibrationthreshold and stayed there for a specific number of acquisitions. When this counter reaches a preset limit(the PRD value) the sensor is finally recalibrated. If on any acquisition the delta is seen to be greater thanthe away from touch recalibration threshold level, the counter is cleared and the away from touch driftingis performed.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
33
-
For example, if the away from touch recalibration delay setting is 10, then the delta has to drop below therecalibration threshold and stay there for 10 acquisitions in succession without going below the thresholdlevel, before the sensor is declared to be recalibrated.
Range: 1 to 255
Default: 20
6.31. Address 43, 105: Calibration Burst Count - Seq1
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
37 Calibration burst count - Seq1 for SelfCap
79 Calibration burst count - Seq1 for MutualCap
This setting represents the total number of measurements carried out during sensor calibration.
Range: 1 to 255
Default: 8
6.32. Address 44, 106: Calibration Burst Count - Seq2
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
38 Calibration burst count - Seq2 for SelfCap
80 Calibration burst count - Seq2 for MutualCap
This setting represents the total number of measurements that is considered for performing driftingreference value during sensor calibration. This value should be less than the Seq1 count value set, asthis is subset of calibration operation.
Range: 1 to 255
Default: 4
6.33. Address 45, 107: Recalibration Threshold
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
39 Recalibration Threshold for SelfCap
81 Recalibration Threshold for MutualCap
Recalibration threshold is the level beyond which automatic recalibration occurs. Recalibration thresholdis expressed as a percentage of the detection threshold setting. This setting is an enumerated value andits settings are as follows:
Setting of 0 = 100% of detect threshold (RECAL_100) Setting of 1 = 50% of detect threshold (RECAL_50) Setting of 2 = 25% of detect threshold (RECAL_25) Setting of 3 = 12.5% of detect threshold (RECAL_12_5)
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
34
-
Setting of 4 = 6.25% of detect threshold (RECAL_6_25)However, an absolute value of 4 is the hard limit for this setting. For example, if the detection threshold is40 and the Recalibration threshold value is set to 4. Although this implies an absolute value of 2 (40 *6.25% = 2.5), it is hard limited to 4.
Range: RECAL_6_25 to RECAL_100Default: RECAL_50
6.34. Address 46-47,108-109: Sensor Post-processing Mode
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
40-41 Sensor post-processing mode for SelfCap
82-83 Sensor post-processing mode for MutualCap
This setting controls the touch library post-processing mode options. Setting of 0 = TOUCH_LIBRARY_DRIVEN Setting of 1 = TOUCH_APPLN_DRIVEN
When TOUCH_LIBRARY_DRIVEN mode is selected, the library self-initiates repeated touchmeasurements to resolve touch press, release and calibration. This mode is suited for best responsetime.
When TOUCH_APPLN_DRIVEN mode is selected, the library does not initiate repeated touchmeasurement to resolve touch press, release and calibration. This mode suits deterministic PTC interruptexecution time for applications requiring stringent CPU time requirements.
Default: 0
6.35. Address 48-49, 110-111: Auto OS Signal Stability Limit
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
48-49 Auto OS signal stability limit for SelfCap
110-111 Auto OS signal stability limit for MutualCap
This setting defines the stability limit of the signals for performing over-samples.
Range: 1 to 1000
Default: 20
6.36. Address 50-51,112-113: Frequency Auto Tune Stability Limit
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
42-43 Frequency auto tune stability limit for SelfCap
84-85 Frequency auto tune stability limit for MutualCap
This setting defines the stability limit of signals for Frequency auto tune calculation.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
35
-
Range: 1 to 1000
Default: 10
Note: This applies only for FREQ_MODE_HOP
6.37. Address 52,114: Frequency Auto Tune In Counter
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
44 Frequency auto tune in counter for SelfCap
86 Frequency auto tune in counter for MutualCap
The DEF_XXXXCAP_FREQ_AUTO_TUNE_IN_CNT parameter is used to trigger the frequency auto tune. Ifsensor signal change at each frequency exceeds the value specified as DEF_XXXXCAP_FREQ_AUTO_SIGNAL_STABILITY_LIMIT for DEF_XXXXCAP_FREQ_AUTO_TUNE_IN_CNT, thenfrequency auto tune will be triggered at this frequency.
Range: 1 to 255
Default: 12
Note: The Frequency Auto Tune feature and related parameters are available only in FREQ_MODE_HOPmode.
6.38. Address 54-55,116-117: Noise Measurement Signal Stability Limit
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
46-47 Noise measurement signal stability limit for SelfCap
88-89 Noise measurement signal stability limit for MutualCap
This setting defines the stability limit of signals for noise calculation.
Range: 1 to1000
Default: 10
6.39. Address 56,118: Noise Measurement Noise LimitThis setting uses to set the noise limit cou
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
48 Noise measurement noise limit for SelfCap
90 Noise measurement noise limit for MutualCap
nter to trigger sensor lockout functionality.
Range: 1 to 255
Default: 12
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
36
-
6.40. Address 57,119: Noise Measurement Sensor Lockout Setting
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
49 Noise measurement sensor lockout setting for SelfCap
91 Noise measurement sensor lockout setting for MutualCap
This setting defines noisy senor lockout setting when the measured noise exceeds the noise limit anddoes not report a touch.
Setting of 0 = SINGLE_SENSOR_LOCKOUT Setting of 1 = GLOBAL_SENSOR_LOCKOUT Setting of 2 = NO_LOCKOUT
Default: 0
6.41. Address 58,120: Noise Measurement Lockout Count Down
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
50 Noise measurement lockout count down for SelfCap
92 Noise measurement lockout count down for MutualCap
If the sensor signal moves from noisy to a good condition and stays there for a Lockout Countdownnumber of measurements, the sensor is unlocked and sensors are ready for touch detection and driftingis enabled.
Note: This parameter is valid only for global lockout.
Range: 1 to 255
Default: 10
6.42. Address 122 125: SelfCap Signal
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
122 SelfCap Button_0 Signal LSB
123 SelfCap Button_0 Signal MSB
124 SelfCap Button_1 Signal LSB
125 SelfCap Button_1 Signal MSB
Addresses 122 125 allow signal data to be read for self-capacitance buttons. There are two bytes ofdata for each button. The 16-bit signal which is accessed as two 8-bit bytes, stored LSB first.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
37
-
6.43. Address 126 129: SelfCap Reference
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
126 SelfCap Button_0 Reference LSB
127 SelfCap Button_0 Reference MSB
128 SelfCap Button_1 Reference LSB
129 SelfCap Button_1 Reference MSB
Addresses 126 129 allow reference data to be read for self-capacitance buttons. There are two bytes ofdata for each button. The 16-bit reference which is accessed as two 8-bit bytes, stored LSB first.
6.44. Address 130-137: MutualCap Signal
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
130 MutualCap Slider Channel_0 Signal LSB
131 MutualCap Slider Channel_0 Signal MSB
132 MutualCap Slider Channel_1 Signal LSB
133 MutualCap Slider Channel_1 Signal MSB
134 MutualCap Slider Channel_2 Signal LSB
135 MutualCap Slider Channel_2 Signal MSB
136 MutualCap Slider Channel_3 Signal LSB
137 MutualCap Slider Channel_3 Signal MSB
Addresses 130 137 allow signal data to be read for each channel of mutual capacitance slider. Thereare two bytes of data for each channel. The 16-bit signal which is accessed as two 8-bit bytes, storedLSB first.
6.45. Address 138-145: MutualCap Reference
Address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
138 MutualCap Slider Channel_0 Reference LSB
139 MutualCap Slider Channel_0 Reference MSB
140 MutualCap Slider Channel_1 Reference LSB
141 MutualCap Slider Channel_1 Reference MSB
142 MutualCap Slider Channel_2 Reference LSB
143 MutualCap Slider Channel_2 Reference MSB
144 MutualCap Slider Channel_3 Reference LSB
145 MutualCap Slider Channel_3 Reference MSB
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
38
-
Addresses 138 145 allow reference data to be read for each channel of mutual capacitance slider. Thereare two bytes of data for each channel. The 16-bit reference which is accessed as two 8-bit bytes, storedLSB first.
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
39
-
7. References SAM D20 PTC User Guide - http://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-
Touch-Controller_User-Guide.pdf Atmel SAM D20 Xplained Pro User Guide - http://www.atmel.com/images/atmel-42102-samd20-
xplained-pro_user-guide.pdf Atmel AVR3009: Driving QTouch Device with IIC Interface - http://www.atmel.com/images/
doc42064.pdf Atmel QTouch Library User Guide - http://www.atmel.com/Images/doc8207.pdf ATSAMD20J18 device datasheet - http://www.atmel.com/Images/Atmel-42129-SAM-
D20_Datasheet.pdf Atmel AT03665: ASF Manual (SAM D20) - http://www.atmel.com/images/atmel-42139-asf-manual-
sam-d20_application-note_at03665.pdf
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
40
http://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-Touch-Controller_User-Guide.pdfhttp://www.atmel.com/Images/Atmel-42195-Qtouch-Library-Peripheral-Touch-Controller_User-Guide.pdfhttp://www.atmel.com/images/atmel-42102-samd20-xplained-pro_user-guide.pdfhttp://www.atmel.com/images/atmel-42102-samd20-xplained-pro_user-guide.pdfhttp://www.atmel.com/images/doc42064.pdfhttp://www.atmel.com/images/doc42064.pdfhttp://www.atmel.com/Images/doc8207.pdfhttp://www.atmel.com/Images/Atmel-42129-SAM-D20_Datasheet.pdfhttp://www.atmel.com/Images/Atmel-42129-SAM-D20_Datasheet.pdfhttp://www.atmel.com/images/atmel-42139-asf-manual-sam-d20_application-note_at03665.pdfhttp://www.atmel.com/images/atmel-42139-asf-manual-sam-d20_application-note_at03665.pdf
-
8. Revision HistoryDoc Rev. Date Comments
42325C 04/2016 Revised for QTouch Library 5.8
42325B 01/2015 Revised for QTouch Library 5.4
42325A 06/2014 Initial document release
Atmel AT08774: SAM D20 PTC with I2C Slave [APPLICATION NOTE]Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
41
-
Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 | www.atmel.com
2016 Atmel Corporation. / Rev.: Atmel-42325C-SAM-D20-PTC-with-I2C-Slave_Application Note-04/2016
Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, QTouch and others are registered trademarks or trademarks of Atmel Corporation inU.S. and other countries. ARM, Cortex, ARM Connected logo, and others are the registered trademarks or trademarks of ARM Ltd. Other terms and productnames may be trademarks of others.
DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to anyintellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS ANDCONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIEDOR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESSINTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISEDOF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of thisdocument and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment toupdate the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotiveapplications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with anyapplications where the failure of such products would reasonably be expected to result in significant personal injury or death (Safety-Critical Applications) withoutan Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for theoperation of nuclear facilities and weapons systems. Atmel products are not designed nor intended for use in military or aerospace applications or environmentsunless specifically designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specificallydesignated by Atmel as automotive-grade.
https://www.facebook.com/AtmelCorporationhttps://twitter.com/Atmelhttp://www.linkedin.com/company/atmel-corporationhttps://plus.google.com/106109247591403112418/postshttp://www.youtube.com/user/AtmelCorporationhttp://en.wikipedia.org/wiki/Atmelhttp://www.atmel.com
IntroductionFeaturesTable of Contents1.Abbreviations and Definitions2.Overview3.Hardware and Functional3.1.Hardware Requisites3.2.Circuit Configuration3.3.Test Setup3.4.Startup/Calibration Times3.5.Calibration3.6.Sleep3.7.Touch Data Debug
4.I2C Operation4.1.I2C-Compatible Address4.2.CHANGE Pin
5.Firmware5.1.Application Flow5.2.Creating Self/Mutual Combined Project5.2.1.Create Self-capacitance Project5.2.2.Create Mutual capacitance Project5.2.3.Create Combined (Self + Mutual capacitance) Project
5.3.Adding ASF Component (SERCOM I2C - Slave Mode Driver)5.4.Configure and Process I2C5.5.Files5.6.Functions
6.Communication Protocol6.1.Introduction6.2.Address 0: Chip ID6.3.Address 1: Major/Minor Code Version6.4.Address 2: SelfCap Sensor Status6.5.Address 3: MutualCap Sensor Status6.6.Address 4: Rotor/Slider Position6.7.Address 6: Calibrate6.8.Address 7: Reset6.9.Address 8: Scan Interval6.10.Address 10-11, 52-55: GAIN6.11.Address 12, 64: Frequency Mode6.12.Address 13-14, 65-68: PTC Prescaler6.13.Address 15-16, 69-72: Series Resistor6.14.Address 17-18, 73-76: PTC Prescaler CC Cal6.15.Address 16, 60: Series Resistor CC Cal6.16.Address 21-23, 81-83: Frequency Hops6.17.Address 24-25, 84-87: Filter Level6.18.Address 26-27, 88-91: Auto OS6.19.Address 28, 92: Auto Tune6.20.Address 29-30, 93: AKS6.21.Address 31-32, 94: Detect Threshold6.22.Address 33-34, 95: Detect Hysteresis6.23.Address 35-36, 96: Position Resolution6.24.Address 97: Position Hysteresis6.25.Address 37, 99: Detect Integration6.26.Address 38, 100: Away From Touch Drift (Positive Drift)6.27.Address 39, 101: Towards Touch Drift (Negative Drift)6.28.Address 40, 102: Max On Duration6.29.Address 41, 103: Drift Hold Time6.30.Address 42, 104: Away from Touch Recalibration Delay6.31.Address 43, 105: Calibration Burst Count - Seq16.32.Address 44, 106: Calibration Burst Count - Seq26.33.Address 45, 107: Recalibration Threshold6.34.Address 46-47,108-109: Sensor Post-processing Mode6.35.Address 48-49, 110-111: Auto OS Signal Stability Limit6.36.Address 50-51,112-113: Frequency Auto Tune Stability Limit6.37.Address 52,114: Frequency Auto Tune In Counter6.38.Address 54-55,116-117: Noise Measurement Signal Stability Limit6.39.Address 56,118: Noise Measurement Noise Limit6.40.Address 57,119: Noise Measurement Sensor Lockout Setting6.41.Address 58,120: Noise Measurement Lockout Count Down6.42.Address 122 125: SelfCap Signal6.43.Address 126 129: SelfCap Reference6.44.Address 130-137: MutualCap Signal6.45.Address 138-145: MutualCap Reference
7.References8.Revision History