English
Language : 

SAM4L Datasheet, PDF (916/1185 Pages) ATMEL Corporation – ATSAM ARM-based Flash MCU
ATSAM4L4/L2
(THRESH.RTHRESH), and a fractional part (THRESH.FTHRESH). The user should select a
threshold value that corresponds to application typical sensor signal strengths. The threshold
values are compared to the LEVEL register values, and the In Touch bit in the Interrupt Status
Register (ISR.INTCH) is set when the value in the LEVEL register is larger than the value in the
THRESH register, while the Out of Touch bit (ISR.OUTTCH) is set when LEVEL becomes less
than half of THRESH, in effect creating a hysteresis between in- and out-of-touch events.
During long touches, the value in the IDLE register will slowly increase and eventually cause a
false out-of-touch event. When the touch is released, the measured value will become smaller
than IDLE, causing a negative response on LEVEL. Writing a one to the Threshold Direction bit
in THRESH (THRESH.DIR) enables negative thresholding, causing the CATB to compare
against -THRESH. During negative thresholding, ISR.INTCH is set when LEVEL goes below the
negative THRESH value, and ISR.OUTTCH is set when LEVEL goes above the negative
THRESH/2 value.
For better noise immunity, a threshold filter can be configured in the Threshold Length field in
THRESH (THRESH.LENGTH). The threshold filter requires a number of samples to be over (or
under, if negative thresholding is used) the threshold before the CATB reports an in- or out-of-
touch event.
34.6.5
Acquisition Clock and Timing
The discharge time of the capacitive sensor over the resistor is measured against CLK_ACQ.
The source for this clock is selected with the Clock Select bit in the Control Register
(CR.CKSEL), and must remain unchanged during CATB operation. The RC oscillator is avail-
able on demand, and the GCLK must be enabled before enabling the CATB. Refer to the
Module Configuration section for the configuration of the generic clock and the RC oscillator.
Before each discharge measurement, the sensor is charged towards the I/O voltage or ground.
Writing to the Charge Time field in CR (CR.CHARGET) selects the charge time duration, if larger
charge times are needed, e.g. for large capacitive loads.
If the measured discharge time is too small, the user can either increase the charge time by
using a larger resistance value for the discharge resistor, or configure the CATB to repeat and
accumulate measurements by writing to the Repeat Measurements field in CNTCR
(CNTCR.REPEAT). Writing a non-zero value to CNTCR.REPEAT will cause the acquisition
block to repeat the acquisition REPEAT+1 times, summing the individual measurements before
sending the sum to the filter block.
34.6.6
Filter Algorithm
The filter in the CATB consists of three main parts: A median3 filter, an Idle tracker, and an aver-
aging filter. The data in the CATB is represented in a fixed-point format consisting of an integer
part and a fractional part. Not all of the LSB’s of the fractional bits might be implemented. Refer
to the Module Configuration section for the number of implemented fractional bits.
The filter in the CATB implements the following recurrence equations:
RAWn = measuredn – IDLEn
mediann = median3(RAWn – 2, RAWn – 1, RAWn)
IDLEn + 1 = IDLEn + TIDLE ⋅ mediann
LEVELn + 1 = LEVELn + TLEVEL ⋅ (mediann – LEVELn)
42023C–SAM–02/2013
916