For the QTouch Libraries, the timing information is provided by the Host Application by updating the ‘time_current_ms’ variable in the Timer ISR. The QTouch Library uses this variable to calculate the necessary timing for Max ON Duration, Drift and Recalibration functionality. Before using the QTouch Libraries, the Timer ISR must be configured appropriately. Also, the Timer Interrupt is used to update the ‘time_to_measure_touch’ variable inorder to start a capacitive touch measurement.
The touch_config.h configuration header file must be used to set the number of channels and charge share delay based on the library used. For example, if the library used is a 12 channel library with 2 csd then QT_NUM_CHANNELS must be specified as 12 and CHARGE_SHARE_DELAY must be specified as 2 in the touch_config_dp.h. This information must be provided irrespective of the number of channels actually used.
The desired number of touch buttons used can be enabled using the qt_enable_key() routine. The channel numbers are sequential from Port A through Port B. Also, individual sensor Threshold, Hysteresis, AKS group and Recalibration parameters can be set using this function call. The Sensor Global Configuration parameters can also be set by the user by directly accessing the global configuration data structure.
When developing a Host application for ATtiny40 device, ensure that the ADC prescalar is set in such a way that it is in the range of 50 KHz to 250 KHz. For example, if the main clock is running at 8MHz then set the ADC prescalar to 32 or more. This must be done to ensure proper touch sensing acquisition.