
CapSense Performance Tuning with User Modules
CY8C20xx7/S CapSense
®
Design Guide
Doc. No. 001-78329 Rev. *E
45
Figure 4-7. Sensor Signal for a Typical Sensor with a Finger Touch
4.3.9 Firmware Design Guidelines
The response time of the CapSense sensors may change due to the increased parasitic capacitance of the sensor. It
is also important to watch the loop execution time (see the following example code), which may also increase. When
the parasitic capacitance of all sensors is less than 10 pF, the firmware routine is executed at a rate of 2.45 ms. This
rate will change if the sensor scan time is increased because of the increase in the parasitic capacitance of the
sensor based on the process variation.
The following is example code for toggling a port pin based on the main loop execution time.
while (1)
{
SmartSense_EMC_PLUS_ScanAllSensors();
SmartSense_EMC_PLUS_UpdateAllBaselines();
if(SmartSense_EMC_PLUS_bIsAnySensorActive() )
{
//1ms firmware routines
}
PRT0DR_Shadow ^= 0x01;
PRT0DR = PRT0DR_Shadow;
}
The period of the signal on the Port_0[1] pin is 4.9 ms (the period is twice the loop time as the port pin is toggled). If
the parasitic capacitance of one sensor is increased to approximately 15 pF, the scan time will change to 1.78 ms;
thus, the period of the signal on Port_0[1] will be 5.6 ms.
If the parasitic capacitance of the sensor is close to the boundary of the SmartSense_EMCPLUS capacitance banks
(for example, 9 pF, which is very close to the 10-pF boundary), SmartSense_EMCPLUS may choose a neighboring
scan time in an application because of process variation. Because of this, different production parts of the same
design can have two different main loop execution times and response times.
Based on the above discussion, firmware should not rely on the scan time of the sensor for implementing other
features (for example, software PWM, software delay, and so on). Programs implementing a watchdog timer (WDT)
should consider this fact while setting the WDT expiration time
A simple firmware implementation example to get a consistent main loop execution time using the Timer16 User
Module follows.
// Main program
BYTE bTimerTicks = 0;
#pragma interrupt_handler myTimer_ISR_Handler;
void myTimer_ISR_Handler( void );