Datasheet

2011 Microchip Technology Inc. DS41391D-page 317
PIC16(L)F1826/27
27.5 Software Control
The software portion of the capacitive sensing module
is required to determine the change in frequency of the
capacitive sensing oscillator. This is accomplished by
the following:
Setting a fixed time base to acquire counts on
Timer0 or Timer1
Establishing the nominal frequency for the
capacitive sensing oscillator
Establishing the reduced frequency for the
capacitive sensing oscillator due to an additional
capacitive load
Set the frequency threshold
27.5.1 NOMINAL FREQUENCY
(NO CAPACITIVE LOAD)
To determine the nominal frequency of the capacitive
sensing oscillator:
Remove any extra capacitive load on the selected
CPSx pin
At the start of the fixed time base, clear the timer
resource
At the end of the fixed time base save the value in
the timer resource
The value of the timer resource is the number of
oscillations of the capacitive sensing oscillator for the
given time base. The frequency of the capacitive
sensing oscillator is equal to the number of counts on
in the timer divided by the period of the fixed time base.
27.5.2 REDUCED FREQUENCY
(ADDITIONAL CAPACITIVE LOAD)
The extra capacitive load will cause the frequency of the
capacitive sensing oscillator to decrease. To determine
the reduced frequency of the capacitive sensing
oscillator:
Add a typical capacitive load on the selected
CPSx pin
Use the same fixed time base as the nominal
frequency measurement
At the start of the fixed time base, clear the timer
resource
At the end of the fixed time base save the value in
the timer resource
The value of the timer resource is the number of oscil-
lations of the capacitive sensing oscillator with an addi-
tional capacitive load. The frequency of the capacitive
sensing oscillator is equal to the number of counts on
in the timer divided by the period of the fixed time base.
This frequency should be less than the value obtained
during the nominal frequency measurement.
27.5.3 FREQUENCY THRESHOLD
The frequency threshold should be placed midway
between the value of nominal frequency and the
reduced frequency of the capacitive sensing oscillator.
Refer to Application Note AN1103, “Software Handling
for Capacitive Sensing” (DS01103) for more detailed
information on the software required for capacitive
sensing module.
27.6 Operation during Sleep
The capacitive sensing oscillator will continue to run as
long as the module is enabled, independent of the part
being in Sleep. In order for the software to determine if
a frequency change has occurred, the part must be
awake. However, the part does not have to be awake
when the timer resource is acquiring counts.
Note: For more information on general capacitive
sensing refer to Application Notes:
AN1101, “Introduction to Capacitive
Sensing” (DS01101)
AN1102, “Layout and Physical
Design Guidelines for Capacitive
Sensing” (DS01102)
Note: Timer0 does not operate when in Sleep,
and therefore cannot be used for
capacitive sense measurements in Sleep.