27. Touch sensing controller (TSC)

27.1 Introduction

The touch sensing controller provides a simple solution for adding capacitive sensing functionality to any application. Capacitive sensing technology is able to detect finger presence near an electrode that is protected from direct touch by a dielectric (for example glass, plastic). The capacitive variation introduced by the finger (or any conductive object) is measured using a proven implementation based on a surface charge transfer acquisition principle.

The touch sensing controller is fully supported by the STMTouch touch sensing firmware library, which is free to use and allows touch sensing functionality to be implemented reliably in the end application.

27.2 TSC main features

The touch sensing controller has the following main features:

Note: The number of capacitive sensing channels is dependent on the size of the packages and subject to IO availability.

27.3 TSC functional description

27.3.1 TSC block diagram

The block diagram of the touch sensing controller is shown in Figure 260 .

Figure 260. TSC block diagram. The diagram shows the internal architecture of the TSC. On the left, an input f_HCLK enters a 'Clock prescalers' block. This block connects to a 'Pulse generator' and a 'Spread spectrum' block. The 'Pulse generator' and 'Spread spectrum' block both connect to a large 'I/O control logic' block. Below the 'I/O control logic' block is a 'Group counters' block containing registers TSC_IOG1CR, TSC_IOG2CR, and TSC_IOGxCR. These registers are connected to the 'I/O control logic' block. The 'I/O control logic' block has multiple output pins labeled SYNC, G1_IO1, G1_IO2, G1_IO3, G1_IO4, G2_IO1, G2_IO2, G2_IO3, G2_IO4, Gx_IO1, Gx_IO2, Gx_IO3, and Gx_IO4. A small label MS30929V1 is in the bottom right corner.

Figure 260. TSC block diagram

Figure 260. TSC block diagram. The diagram shows the internal architecture of the TSC. On the left, an input f_HCLK enters a 'Clock prescalers' block. This block connects to a 'Pulse generator' and a 'Spread spectrum' block. The 'Pulse generator' and 'Spread spectrum' block both connect to a large 'I/O control logic' block. Below the 'I/O control logic' block is a 'Group counters' block containing registers TSC_IOG1CR, TSC_IOG2CR, and TSC_IOGxCR. These registers are connected to the 'I/O control logic' block. The 'I/O control logic' block has multiple output pins labeled SYNC, G1_IO1, G1_IO2, G1_IO3, G1_IO4, G2_IO1, G2_IO2, G2_IO3, G2_IO4, Gx_IO1, Gx_IO2, Gx_IO3, and Gx_IO4. A small label MS30929V1 is in the bottom right corner.

27.3.2 Surface charge transfer acquisition overview

The surface charge transfer acquisition is a proven, robust and efficient way to measure a capacitance. It uses a minimum number of external components to operate with a single ended electrode type. This acquisition is designed around an analog I/O group composed of up to four GPIOs (see Figure 261 ). Several analog I/O groups are available to allow the acquisition of several capacitive sensing channels simultaneously and to support a larger number of capacitive sensing channels. Within a same analog I/O group, the acquisition of the capacitive sensing channels is sequential.

One of the GPIOs is dedicated to the sampling capacitor \( C_S \) . Only one sampling capacitor I/O per analog I/O group must be enabled at a time.

The remaining GPIOs are dedicated to the electrodes and are commonly called channels. For some specific needs (such as proximity detection), it is possible to simultaneously enable more than one channel per analog I/O group.

Figure 261. Surface charge transfer analog I/O group structure

Figure 261. Surface charge transfer analog I/O group structure. The diagram shows three electrodes (Electrode 1, Electrode 2, Electrode 3) connected to an analog I/O group. Each electrode is connected to a series resistor (Rs1, Rs2, Rs3) which is then connected to a GPIO pin (Gx_IO1, Gx_IO2, Gx_IO3, Gx_IO4). Each electrode also has a parasitic capacitance (Cx1, Cx2, Cx3) connected to ground. A sampling capacitor (Cs) is connected to the Gx_IO2 pin, with a voltage Vcs across it. The analog I/O group contains four switches and four comparators. The switches connect the GPIO pins to the comparators. The comparators compare the voltage at the GPIO pins to a threshold voltage (VSENSOR). The diagram is labeled MSV30930V3.
Figure 261. Surface charge transfer analog I/O group structure. The diagram shows three electrodes (Electrode 1, Electrode 2, Electrode 3) connected to an analog I/O group. Each electrode is connected to a series resistor (Rs1, Rs2, Rs3) which is then connected to a GPIO pin (Gx_IO1, Gx_IO2, Gx_IO3, Gx_IO4). Each electrode also has a parasitic capacitance (Cx1, Cx2, Cx3) connected to ground. A sampling capacitor (Cs) is connected to the Gx_IO2 pin, with a voltage Vcs across it. The analog I/O group contains four switches and four comparators. The switches connect the GPIO pins to the comparators. The comparators compare the voltage at the GPIO pins to a threshold voltage (VSENSOR). The diagram is labeled MSV30930V3.

Note: \( Gx\_IOy \) where \( x \) is the analog I/O group number and \( y \) the GPIO number within the selected group.

The surface charge transfer acquisition principle consists of charging an electrode capacitance ( \( C_X \) ) and transferring a part of the accumulated charge into a sampling capacitor ( \( C_S \) ). This sequence is repeated until the voltage across \( C_S \) reaches a given threshold ( \( V_{IH} \) in our case). The number of charge transfers required to reach the threshold is a direct representation of the size of the electrode capacitance.

Table 99 details the charge transfer acquisition sequence of the capacitive sensing channel 1. States 3 to 7 are repeated until the voltage across \( C_S \) reaches the given threshold. The same sequence applies to the acquisition of the other channels. The electrode serial resistor \( R_S \) improves the ESD immunity of the solution.

Table 99. Acquisition sequence summary

StateGx_IO1 (channel)Gx_IO2 (sampling)Gx_IO3 (channel)Gx_IO4 (channel)State description
#1Input floating with analog switch closedOutput open-drain low with analog switch closedInput floating with analog switch closedDischarge all \( C_X \) and \( C_S \)
#2Input floatingDead time
#3Output push-pull highInput floatingCharge \( C_{X1} \)
#4Input floatingDead time
#5Input floating with analog switch closedInput floatingCharge transfer from \( C_{X1} \) to \( C_S \)
#6Input floatingDead time
#7Input floatingMeasure \( C_S \) voltage

Note: Gx_IOy where x is the analog I/O group number and y the GPIO number within the selected group.

The voltage variation over the time on the sampling capacitor \( C_S \) is detailed below (refer to Figure 261 for \( V_{SENSOR} \) and \( V_{CS} \) definition):

Figure 262. Sampling capacitor voltage variation

Graph showing the sampling capacitor voltage variation (Vcs) over time (t) during two acquisition sequences, S1 and S2. The y-axis represents voltage, with markers for V_SENSOR, Vcs, VDD, and VIH. The x-axis represents time (t). The graph shows a series of blue rectangular pulses representing the sampling capacitor voltage (Vcs) and a yellow curve representing the sensor voltage (VSENSOR). The voltage rises exponentially towards VDD during the charging phase and drops to a lower level during the discharge phase. The sequences S1 and S2 are separated by a vertical line.

The graph illustrates the voltage variation of the sampling capacitor \( V_{CS} \) (yellow curve) and the sensor voltage \( V_{SENSOR} \) (blue pulses) over time \( t \) . The y-axis shows voltage levels \( V_{SENSOR} \) , \( V_{CS} \) , \( V_{DD} \) , and \( V_{IH} \) . The x-axis is time \( t \) . The graph is divided into two acquisition sequences, S1 and S2, by a vertical line. In each sequence, the voltage \( V_{CS} \) rises exponentially towards \( V_{DD} \) during the charging phase and drops to a lower level during the discharge phase. The sensor voltage \( V_{SENSOR} \) is shown as a series of blue rectangular pulses.

Graph showing the sampling capacitor voltage variation (Vcs) over time (t) during two acquisition sequences, S1 and S2. The y-axis represents voltage, with markers for V_SENSOR, Vcs, VDD, and VIH. The x-axis represents time (t). The graph shows a series of blue rectangular pulses representing the sampling capacitor voltage (Vcs) and a yellow curve representing the sensor voltage (VSENSOR). The voltage rises exponentially towards VDD during the charging phase and drops to a lower level during the discharge phase. The sequences S1 and S2 are separated by a vertical line.

27.3.3 Reset and clocks

The TSC clock source is the AHB clock (HCLK). Two programmable prescalers are used to generate the pulse generator and the spread spectrum internal clocks:

The reset and clock controller (RCC) provides dedicated bits to enable the touch sensing controller clock and to reset this peripheral. For more information, refer to Section 7: Reset and clock control (RCC) .

27.3.4 Charge transfer acquisition sequence

An example of a charge transfer acquisition sequence is detailed in Figure 263 .

Figure 263. Charge transfer acquisition sequence

Timing diagram showing the charge transfer acquisition sequence. The diagram plots three signals over time: CLK_AHB (a periodic square wave), Cx (channel I/O), and Cs (sampling capacitor I/O). The sequence starts with a 'Discharge Cx and Cs' state where both signals are at 0V. This is followed by a 'Dead time state' (both signals high impedance). Then, a 'Pulse high state (charge of Cx)' occurs where Cx goes to 1V and Cs stays at 0V. This is followed by another 'Dead time state'. Next, a 'Pulse low state (charge transfer from Cx to Cs)' occurs where Cx goes to 0V and Cs goes to 1V. This is followed by a 'Cs reading' state where Cs is read while both signals are high impedance. Then, another 'Dead time state'. The sequence repeats with a 'Pulse high state', a 'Spread spectrum state' (a variable duration where Cx is high and Cs is high impedance), a 'Dead time state', a 'Pulse low state', another 'Cs reading' state, and a final 'Dead time state'. The 'Charge transfer frequency' is indicated by a double-headed arrow spanning the duration of one full cycle (Pulse high + Dead time + Pulse low + Dead time). The diagram is labeled MSV30932V3 at the bottom right.
Timing diagram showing the charge transfer acquisition sequence. The diagram plots three signals over time: CLK_AHB (a periodic square wave), Cx (channel I/O), and Cs (sampling capacitor I/O). The sequence starts with a 'Discharge Cx and Cs' state where both signals are at 0V. This is followed by a 'Dead time state' (both signals high impedance). Then, a 'Pulse high state (charge of Cx)' occurs where Cx goes to 1V and Cs stays at 0V. This is followed by another 'Dead time state'. Next, a 'Pulse low state (charge transfer from Cx to Cs)' occurs where Cx goes to 0V and Cs goes to 1V. This is followed by a 'Cs reading' state where Cs is read while both signals are high impedance. Then, another 'Dead time state'. The sequence repeats with a 'Pulse high state', a 'Spread spectrum state' (a variable duration where Cx is high and Cs is high impedance), a 'Dead time state', a 'Pulse low state', another 'Cs reading' state, and a final 'Dead time state'. The 'Charge transfer frequency' is indicated by a double-headed arrow spanning the duration of one full cycle (Pulse high + Dead time + Pulse low + Dead time). The diagram is labeled MSV30932V3 at the bottom right.

For higher flexibility, the charge transfer frequency is fully configurable. Both the pulse high state (charge of \( C_X \) ) and the pulse low state (transfer of charge from \( C_X \) to \( C_S \) ) duration can be defined using the CTPH[3:0] and CTPL[3:0] bits in the TSC_CR register. The standard range for the pulse high and low states duration is 500 ns to 2 µs. To ensure a correct measurement of the electrode capacitance, the pulse high state duration must be set to ensure that \( C_X \) is always fully charged.

A dead time where both the sampling capacitor I/O and the channel I/O are in input floating state is inserted between the pulse high and low states to ensure an optimum charge transfer acquisition sequence. This state duration is 2 periods of HCLK.

At the end of the pulse high state and if the spread spectrum feature is enabled, a variable number of periods of the SSCLK clock are added.

The reading of the sampling capacitor I/O, to determine if the voltage across \( C_S \) has reached the given threshold, is performed at the end of the pulse low state.

Note: The following TSC control register configurations are forbidden:

27.3.5 Spread spectrum feature

The spread spectrum feature generates a variation of the charge transfer frequency. This is done to improve the robustness of the charge transfer acquisition in noisy environments and also to reduce the induced emission. The maximum frequency variation is in the range of 10% to 50% of the nominal charge transfer period. For instance, for a nominal charge transfer frequency of 250 kHz (4 \( \mu\text{s} \) ), the typical spread spectrum deviation is 10% (400 ns) which leads to a minimum charge transfer frequency of ~227 kHz.

In practice, the spread spectrum consists of adding a variable number of SSCLK periods to the pulse high state using the principle shown below:

Figure 264. Spread spectrum variation principle

Figure 264: Spread spectrum variation principle. A graph showing 'Deviation value' on the y-axis (ranging from 0 to (SSD + 1)) versus 'Number of pulses' on the x-axis. The curve shows a step-like variation, peaking at (SSD + 1) around pulse n, and returning to 0 around pulse n+1. The x-axis is marked with n-1, n, and n+1. The y-axis has markers at 0, 1, 2, 3, and (SSD + 1). A small label 'MS30933V1' is in the bottom right corner of the graph area.
Figure 264: Spread spectrum variation principle. A graph showing 'Deviation value' on the y-axis (ranging from 0 to (SSD + 1)) versus 'Number of pulses' on the x-axis. The curve shows a step-like variation, peaking at (SSD + 1) around pulse n, and returning to 0 around pulse n+1. The x-axis is marked with n-1, n, and n+1. The y-axis has markers at 0, 1, 2, 3, and (SSD + 1). A small label 'MS30933V1' is in the bottom right corner of the graph area.

The table below details the maximum frequency deviation with different HCLK settings:

Table 100. Spread spectrum deviation versus AHB clock frequency

\( f_{\text{HCLK}} \)Spread spectrum stepMaximum spread spectrum deviation
24 MHz41.6 ns10666.6 ns
48 MHz20.8 ns5333.3 ns

The spread spectrum feature can be disabled/enabled using the SSE bit in the TSC_CR register. The frequency deviation is also configurable to accommodate the device HCLK clock frequency and the selected charge transfer frequency through the SSPSC and SSD[6:0] bits in the TSC_CR register.

27.3.6 Max count error

The max count error prevents long acquisition times resulting from a faulty capacitive sensing channel. It consists of specifying a maximum count value for the analog I/O group counters. This maximum count value is specified using the MCV[2:0] bits in the TSC_CR register. As soon as an acquisition group counter reaches this maximum value, the ongoing acquisition is stopped and the end of acquisition (EOAF bit) and max count error (MCEF bit) flags are both set. An interrupt can also be generated if the corresponding end of acquisition (EOAIE bit) or/and max count error (MCEIE bit) interrupt enable bits are set.

27.3.7 Sampling capacitor I/O and channel I/O mode selection

To allow the GPIOs to be controlled by the touch sensing controller, the corresponding alternate function must be enabled through the standard GPIO registers and the GPIOxAFR registers.

The GPIOs modes controlled by the TSC are defined using the TSC_IOSCR and TSC_IOCCR register.

When there is no ongoing acquisition, all the I/Os controlled by the touch sensing controller are in default state. While an acquisition is ongoing, only unused I/Os (neither defined as sampling capacitor I/O nor as channel I/O) are in default state. The IODEF bit in the TSC_CR register defines the configuration of the I/Os which are in default state. The table below summarizes the configuration of the I/O depending on its mode.

Table 101. I/O state depending on its mode and IODEF bit value

IODEF bitAcquisition statusUnused I/O modeChannel I/O modeSampling capacitor I/O mode
0
(output push-pull low)
NoOutput push-pull lowOutput push-pull lowOutput push-pull low
0
(output push-pull low)
OngoingOutput push-pull low--
1
(input floating)
NoInput floatingInput floatingInput floating
1
(input floating)
OngoingInput floating--

Unused I/O mode

An unused I/O corresponds to a GPIO controlled by the TSC peripheral but not defined as an electrode I/O nor as a sampling capacitor I/O.

Sampling capacitor I/O mode

To allow the control of the sampling capacitor I/O by the TSC peripheral, the corresponding GPIO must be first set to alternate output open drain mode and then the corresponding Gx_IOy bit in the TSC_IOSCR register must be set.

Only one sampling capacitor per analog I/O group must be enabled at a time.

Channel I/O mode

To allow the control of the channel I/O by the TSC peripheral, the corresponding GPIO must be first set to alternate output push-pull mode and the corresponding Gx_IOy bit in the TSC_IOCCR register must be set.

For proximity detection where a higher equivalent electrode surface is required or to speed-up the acquisition process, it is possible to enable and simultaneously acquire several channels belonging to the same analog I/O group.

Note: During the acquisition phase and even if the TSC peripheral alternate function is not enabled, as soon as the TSC_IOSCR or TSC_IOCCR bit is set, the corresponding GPIO analog switch is automatically controlled by the touch sensing controller.

27.3.8 Acquisition mode

The touch sensing controller offers two acquisition modes:

The GxE bits in the TSC_IOGCSR registers specify which analog I/O groups are enabled (corresponding counter is counting). The \( C_S \) voltage of a disabled analog I/O group is not monitored and this group does not participate in the triggering of the end of acquisition flag. However, if the disabled analog I/O group contains some channels, they are pulsed.

When the \( C_S \) voltage of an enabled analog I/O group reaches the given threshold, the corresponding GxS bit of the TSC_IOGCSR register is set. When the acquisition of all enabled analog I/O groups is complete (all GxS bits of all enabled analog I/O groups are set), the EOAF flag in the TSC_ISR register is set. An interrupt request is generated if the EOAIE bit in the TSC_IER register is set.

In the case that a max count error is detected, the ongoing acquisition is stopped and both the EOAF and MCEF flags in the TSC_ISR register are set. Interrupt requests can be generated for both events if the corresponding bits (EOAIE and MCEIE bits of the TSCIER register) are set. Note that when the max count error is detected the remaining GxS bits in the enabled analog I/O groups are not set.

To clear the interrupt flags, the corresponding EOAIC and MCEIC bits in the TSC_ICR register must be set.

The analog I/O group counters are cleared when a new acquisition is started. They are updated with the number of charge transfer cycles generated on the corresponding channel(s) upon the completion of the acquisition.

27.3.9 I/O hysteresis and analog switch control

In order to offer a higher flexibility, the touch sensing controller is able to take the control of the Schmitt trigger hysteresis and analog switch of each Gx_IOy. This control is available whatever the I/O control mode is (controlled by standard GPIO registers or other peripherals) assuming that the touch sensing controller is enabled. This may be useful to perform a different acquisition sequence or for other purposes.

In order to improve the system immunity, the Schmitt trigger hysteresis of the GPIOs controlled by the TSC must be disabled by resetting the corresponding Gx_IOy bit in the TSC_IOHCR register.

27.4 TSC low-power modes

Table 102. Effect of low-power modes on TSC

ModeDescription
SleepNo effect
TSC interrupts cause the device to exit Sleep mode.
StopTSC registers are frozen
The TSC stops its operation until the Stop or Standby mode is exited.
Standby

27.5 TSC interrupts

Table 103. Interrupt control bits

Interrupt eventEnable control bitEvent flagClear flag bitExit the Sleep modeExit the Stop modeExit the Standby mode
End of acquisitionEOAIEEOAIFEOAICYesNoNo
Max count errorMCEIEMCEIFMCEICYesNoNo

27.6 TSC registers

Refer to Section 1.2 on page 36 of the reference manual for a list of abbreviations used in register descriptions.

The peripheral registers can be accessed by words (32-bit).

27.6.1 TSC control register (TSC_CR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
CTPH[3:0]CTPL[3:0]SSD[6:0]SSE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SSPSCPGPSC[2:0]Res.Res.Res.Res.MCV[2:0]IODEFSYNC POLAMSTARTTSCE
rwrwrwrwrwrwrwrwrwrwrwrw
Bits 31:28 CTPH[3:0] : Charge transfer pulse high

These bits are set and cleared by software. They define the duration of the high state of the charge transfer pulse (charge of \( C_X \) ).

0000: \( 1 \times t_{PGCLK} \)

0001: \( 2 \times t_{PGCLK} \)

...

1111: \( 16 \times t_{PGCLK} \)

Note: These bits must not be modified when an acquisition is ongoing.

Bits 27:24 CTPL[3:0] : Charge transfer pulse low

These bits are set and cleared by software. They define the duration of the low state of the charge transfer pulse (transfer of charge from \( C_X \) to \( C_S \) ).

0000: \( 1 \times t_{PGCLK} \)

0001: \( 2 \times t_{PGCLK} \)

...

1111: \( 16 \times t_{PGCLK} \)

Note: These bits must not be modified when an acquisition is ongoing.

Note: Some configurations are forbidden. Refer to the Section 27.3.4: Charge transfer acquisition sequence for details.

Bits 23:17 SSD[6:0] : Spread spectrum deviation

These bits are set and cleared by software. They define the spread spectrum deviation which consists in adding a variable number of periods of the SSCLK clock to the charge transfer pulse high state.

0000000: \( 1 \times t_{SSCLK} \)

0000001: \( 2 \times t_{SSCLK} \)

...

1111111: \( 128 \times t_{SSCLK} \)

Note: These bits must not be modified when an acquisition is ongoing.

Bit 16 SSE : Spread spectrum enable

This bit is set and cleared by software to enable/disable the spread spectrum feature.

0: Spread spectrum disabled

1: Spread spectrum enabled

Note: This bit must not be modified when an acquisition is ongoing.

Bit 15 SSPSC : Spread spectrum prescaler

This bit is set and cleared by software. It selects the AHB clock divider used to generate the spread spectrum clock (SSCLK).

0: \( f_{HCLK} \)

1: \( f_{HCLK} / 2 \)

Note: This bit must not be modified when an acquisition is ongoing.

Bits 14:12 PGPSC[2:0] : Pulse generator prescaler

These bits are set and cleared by software. They select the AHB clock divider used to generate the pulse generator clock (PGCLK).

000: \( f_{HCLK} \)
001: \( f_{HCLK} / 2 \)
010: \( f_{HCLK} / 4 \)
011: \( f_{HCLK} / 8 \)
100: \( f_{HCLK} / 16 \)
101: \( f_{HCLK} / 32 \)
110: \( f_{HCLK} / 64 \)
111: \( f_{HCLK} / 128 \)

Note: These bits must not be modified when an acquisition is ongoing.

Note: Some configurations are forbidden. Refer to the Section 27.3.4: Charge transfer acquisition sequence for details.

Bits 11:8 Reserved, must be kept at reset value.

Bits 7:5 MCV[2:0] : Max count value

These bits are set and cleared by software. They define the maximum number of charge transfer pulses that can be generated before a max count error is generated.

000: 255
001: 511
010: 1023
011: 2047
100: 4095
101: 8191
110: 16383
111: reserved

Note: These bits must not be modified when an acquisition is ongoing.

Bit 4 IODEF : I/O Default mode

This bit is set and cleared by software. It defines the configuration of all the TSC I/Os when there is no ongoing acquisition. When there is an ongoing acquisition, it defines the configuration of all unused I/Os (not defined as sampling capacitor I/O or as channel I/O).

0: I/Os are forced to output push-pull low
1: I/Os are in input floating

Note: This bit must not be modified when an acquisition is ongoing.

Bit 3 SYNCPOL : Synchronization pin polarity

This bit is set and cleared by software to select the polarity of the synchronization input pin.

0: Falling edge only
1: Rising edge and high level

Bit 2 AM : Acquisition mode

This bit is set and cleared by software to select the acquisition mode.

0: Normal acquisition mode (acquisition starts as soon as START bit is set)

1: Synchronized acquisition mode (acquisition starts if START bit is set and when the selected signal is detected on the SYNC input pin)

Note: This bit must not be modified when an acquisition is ongoing.

Bit 1 START : Start a new acquisition

This bit is set by software to start a new acquisition. It is cleared by hardware as soon as the acquisition is complete or by software to cancel the ongoing acquisition.

0: Acquisition not started

1: Start a new acquisition

Bit 0 TSCE : Touch sensing controller enable

This bit is set and cleared by software to enable/disable the touch sensing controller.

0: Touch sensing controller disabled

1: Touch sensing controller enabled

Note: When the touch sensing controller is disabled, TSC registers settings have no effect.

27.6.2 TSC interrupt enable register (TSC_IER)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEIEEOAIE
rwrw

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 MCEIE : Max count error interrupt enable

This bit is set and cleared by software to enable/disable the max count error interrupt.

0: Max count error interrupt disabled

1: Max count error interrupt enabled

Bit 0 EOAIE : End of acquisition interrupt enable

This bit is set and cleared by software to enable/disable the end of acquisition interrupt.

0: End of acquisition interrupt disabled

1: End of acquisition interrupt enabled

27.6.3 TSC interrupt clear register (TSC_ICR)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEICEOAIC
nwnw

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 MCEIC : Max count error interrupt clear

This bit is set by software to clear the max count error flag and it is cleared by hardware when the flag is reset. Writing a '0' has no effect.

0: No effect

1: Clears the corresponding MCEF of the TSC_ISR register

Bit 0 EOAIC : End of acquisition interrupt clear

This bit is set by software to clear the end of acquisition flag and it is cleared by hardware when the flag is reset. Writing a '0' has no effect.

0: No effect

1: Clears the corresponding EOAF of the TSC_ISR register

27.6.4 TSC interrupt status register (TSC_ISR)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEFEOAF
rr

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 MCEF : Max count error flag

This bit is set by hardware as soon as an analog I/O group counter reaches the max count value specified. It is cleared by software writing 1 to the bit MCEIC of the TSC_ICR register.

0: No max count error (MCE) detected

1: Max count error (MCE) detected

Bit 0 EOAF : End of acquisition flag

This bit is set by hardware when the acquisition of all enabled group is complete (all GxS bits of all enabled analog I/O groups are set or when a max count error is detected). It is cleared by software writing 1 to the bit EOAIC of the TSC_ICR register.

0: Acquisition is ongoing or not started

1: Acquisition is complete

27.6.5 TSC I/O hysteresis control register (TSC_IOHCR)

Address offset: 0x10

Reset value: 0xFFFF FFFF

31302928272625242322212019181716
G8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 Gx_IOy : Gx_IOy Schmitt trigger hysteresis mode

These bits are set and cleared by software to enable/disable the Gx_IOy Schmitt trigger hysteresis.

0: Gx_IOy Schmitt trigger hysteresis disabled

1: Gx_IOy Schmitt trigger hysteresis enabled

Note: These bits control the I/O Schmitt trigger hysteresis whatever the I/O control mode is (even if controlled by standard GPIO registers).

27.6.6 TSC I/O analog switch control register (TSC_IOASCR)

Address offset: 0x18

Reset value: 0x0000 0000

31302928272625242322212019181716
G8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 Gx_IOy : Gx_IOy analog switch enable

These bits are set and cleared by software to enable/disable the Gx_IOy analog switch.

0: Gx_IOy analog switch disabled (opened)

1: Gx_IOy analog switch enabled (closed)

Note: These bits control the I/O analog switch whatever the I/O control mode is (even if controlled by standard GPIO registers).

27.6.7 TSC I/O sampling control register (TSC_IOSCR)

Address offset: 0x20

Reset value: 0x0000 0000

31302928272625242322212019181716
G8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 Gx_IOy : Gx_IOy sampling mode

These bits are set and cleared by software to configure the Gx_IOy as a sampling capacitor I/O. Only one I/O per analog I/O group must be defined as sampling capacitor.

0: Gx_IOy unused

1: Gx_IOy used as sampling capacitor

Note: These bits must not be modified when an acquisition is ongoing.

During the acquisition phase and even if the TSC peripheral alternate function is not enabled, as soon as the TSC_IOSCR bit is set, the corresponding GPIO analog switch is automatically controlled by the touch sensing controller.

27.6.8 TSC I/O channel control register (TSC_IOCCR)

Address offset: 0x28

Reset value: 0x0000 0000

31302928272625242322212019181716
G8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 Gx_IOy : Gx_IOy channel mode

These bits are set and cleared by software to configure the Gx_IOy as a channel I/O.

0: Gx_IOy unused

1: Gx_IOy used as channel

Note: These bits must not be modified when an acquisition is ongoing.

During the acquisition phase and even if the TSC peripheral alternate function is not enabled, as soon as the TSC_IOCCR bit is set, the corresponding GPIO analog switch is automatically controlled by the touch sensing controller.

27.6.9 TSC I/O group control status register (TSC_IOGCSR)

Address offset: 0x30

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.G8SG7SG6SG5SG4SG3SG2SG1S
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.G8EG7EG6EG5EG4EG3EG2EG1E
rwrwrwrwrwrwrwrw

Bits 31:24 Reserved, must be kept at reset value.

Bits 23:16 GxS : Analog I/O group x status

These bits are set by hardware when the acquisition on the corresponding enabled analog I/O group x is complete. They are cleared by hardware when a new acquisition is started.

0: Acquisition on analog I/O group x is ongoing or not started

1: Acquisition on analog I/O group x is complete

Note: When a max count error is detected the remaining GxS bits of the enabled analog I/O groups are not set.

Bits 15:8 Reserved, must be kept at reset value.

Bits 7:0 GxE : Analog I/O group x enable

These bits are set and cleared by software to enable/disable the acquisition (counter is counting) on the corresponding analog I/O group x.

0: Acquisition on analog I/O group x disabled

1: Acquisition on analog I/O group x enabled

27.6.10 TSC I/O group x counter register (TSC_IOGxCR)

x represents the analog I/O group number.

Address offset: 0x30 + 0x04 * x, (x = 1 to 8)

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.CNT[13:0]
rrrrrrrrrrrrrr

Bits 31:14 Reserved, must be kept at reset value.

Bits 13:0 CNT[13:0] : Counter value

These bits represent the number of charge transfer cycles generated on the analog I/O group x to complete its acquisition (voltage across \( C_S \) has reached the threshold).

27.6.11 TSC register map

Table 104. TSC register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x0000TSC_CRCTPH[3:0]CTPL[3:0]SSD[6:0]SSESSPSCPGPSC[2:0]Res.Res.Res.Res.Res.MCV [2:0]IODEFSYNCPOLAMSTARTTSCE
Reset value0000000000000000000000000000
0x0004TSC_IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEIEEOAIE
Reset value00
0x0008TSC_ICRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEICEOAIC
Reset value00
0x000CTSC_ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MCEFEOAF
Reset value00
0x0010TSC_IOHCRG8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
Reset value11111111111111111111111111111111
0x0014Reserved
0x0018TSC_IOASCRG8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
Reset value00000000000000000000000000000000
0x001CReserved
0x0020TSC_IOSCRG8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
Reset value00000000000000000000000000000000
0x0024Reserved
0x0028TSC_IOCCRG8_IO4G8_IO3G8_IO2G8_IO1G7_IO4G7_IO3G7_IO2G7_IO1G6_IO4G6_IO3G6_IO2G6_IO1G5_IO4G5_IO3G5_IO2G5_IO1G4_IO4G4_IO3G4_IO2G4_IO1G3_IO4G3_IO3G3_IO2G3_IO1G2_IO4G2_IO3G2_IO2G2_IO1G1_IO4G1_IO3G1_IO2G1_IO1
Reset value00000000000000000000000000000000
0x002CReserved
0x0030TSC_IOGCSRRes.Res.Res.Res.Res.Res.Res.Res.G8SG7SG6SG5SG4SG3SG2SG1SRes.Res.Res.Res.Res.Res.Res.Res.Res.G8EG7EG6EG5EG4EG3EG2EG1E
Reset value0000000000000000
0x0034TSC_IOG1CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value00000000000000
0x0038TSC_IOG2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value00000000000000

Table 104. TSC register map and reset values (continued)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x003CTSC_IOG3CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value00000000000000
0x0040TSC_IOG4CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value0000000000000
0x0044TSC_IOG5CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value0000000000000
0x0048TSC_IOG6CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value0000000000000
0x004CTSC_IOG7CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value0000000000000
0x0050TSC_IOG8CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CNT[13:0]
Reset value0000000000000

Refer to Section 2.2 on page 40 for the register boundary addresses.