Spread spectrum
Without spread spectrum, the main noise susceptibility is found at the acquisition frequency and its value is 1/TCD (TCD = transfer cycle duration).
The main frequency (HCLK) in the STM32 MCUs comes from the PLL output. Preferably the highest frequency recommended by specification is used to offer an optimum response time (example: 48 MHz for the STM32F0 series).
This frequency is divided in the TSC cell by the programmable prescaler (PGCLK). This frequency determines the basic timing units for CTPH, CTPL as follows:
Transfer cycle duration = (1/ (PGCLK) x ((CTPH + 1) + (CTPL + 1))) + (dead time = 2 x 1/ (HCLK)
with dead time = 2
By enabling the spread spectrum feature (with the SSE, spread spectrum enable), the noise susceptibility is distributed on multiple frequencies. This is done by adding HCLK timing units (period) to CTPH.
The SSD, spread spectrum deviation) allows the number of distributed frequencies to be set as follows:
from 0 (1 x tSSCLK) to 127 (128 x tSSCLK)
Setting SSD to 32 gives usually good results.
The negative impact of this feature is the degradation of the acquisition speed and thus the response time. For example, SSD set to 127 adds an average of 64 x (1/ 48 MHz) = 1.33 µs to each count. For a 2000 counts acquisition duration, 2.6 ms is added due to spread spectrum activation.
Usually end users need a response time in less than 60 ms. Assuming the application uses three banks, the individual acquisition must be reported in less than 20 ms. If moreover a debounce filter is used (set to 2), this time constraint must be divided further by a factor of three. This leads to a maximum target time for one acquisition equal to 6.6 ms.
One acquisition time = count number x transfer cycle duration (see the transfer-cycle duration formula above)
TSL, HAL_TSC_Init must be called with the following parameters:htsc.Instance = TSC;
…
htsc.Init.SpreadSpectrum = ENABLE;
htsc.Init.SpreadSpectrumDeviation = 32;
htsc.Init.SpreadSpectrumPrescaler = TSC_SS_PRESC_DIV1;
…
if (HAL_TSC_Init(&htsc) != HAL_OK)
{
Error_Handler();
}
SpreadSpectrumDeviationis SSD (from 1 to 127 when SSE = 1); typically set to 32SpreadSpectrumPrescaleris SSPSC (spread spectrum prescaler); can be divide-by-one or divide‑by‑two.
- The spread spectrum decreases the impact when the noise is applied but this effect applies to a larger frequency spectrum.
- When using frequency hopping, only one of the acquisition frequencies must be impacted by the noise. It is important that only one acquisition frequency is impacted by one noise frequency.
- While the noise frequency is between the two acquisition frequencies, it must not impact both of them. It may be the case while the spread spectrum is enabled.




