Skip to main content
John_1992
Associate II
August 11, 2021
Solved

TSC measurement after exiting STOP mode (Abnormal delta)

  • August 11, 2021
  • 5 replies
  • 1880 views

Hi,

MCU: STM32L072

MCU is using TSC and ST touch sense library.

When there is no stop mode involved, the measurement delta of no pressing is normal (-1, 0, 1).

If MCU enters stop mode and then exits stop mode for touch sensing measurement, the delta would be much higher (6, 7).

However, the delta would become normal again in following situation.

  1. Wait up from STOP mode and the wait about 200ms to start TSC measurement.
  2. After exiting stop mode, keep MCU running without entering stop mode again, the delta would become normal after some period of time (MCU would keep measuring touch sensing every 500ms).

The clock setting should be the same because program would call SystemClock_Config() after exiting stop mode.

void EnterStopMode(void)
{
	// Enable Ultra low power mode
	HAL_PWREx_EnableUltraLowPower();
 
	// Disable the fast wake up from Ultra low power mode
	HAL_PWREx_DisableFastWakeUp();
 
	// Select HSI as system clock source after Wake Up from Stop mode
	__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
 
	HAL_SuspendTick();
	HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
	// In Stop mode
	// Wake up
	HAL_ResumeTick();
 SystemClock_Config();
}

I would like to know why the TSC measurement need to wait a period of time after exiting stop mode in order to get normal reading.

This topic has been closed for replies.
Best answer by OlivierR

John,

I reproduce and understand this behavior.

  • After a power-up sequence, all peripherals/gpios/Interconnect are in a default state (to simplify).
    • If you start TSC acquisition, Ref&Measure will be compute taking into account all these system setting. Let's call Meas1.
    • If you move to EnterStopMode(), after exiting from STOP mode, all peripherals/gpios/Interconnect system setting are not the same.
    • A new TSC acquisition will give Meas2
  • To avoid this behavior call EnterStopMode() before the first TSC acquisition. Doing this, Mea and Ref will be measure/compute every time in the same system context. Algo can be
    • Power-up
    • Peripherals Init (GPIO, TSC, Sysclk)
    • Label ici
    • EnterStopMode()
    • Start TSC acquisition
    • Wait end of TSC acquisition
    • Call ECS api
    • goto ici

Find attached software example based on DISCO-L053.

Olivier

5 replies

OlivierR
ST Employee
August 25, 2021

Hello John,

Can you share Measure, Reference and sampling capacitances values?

This can be due to incomplete charge/transfer/discharge cycles, ECS or parasitic capacitance:

  • In normal mode, between acquisition, discharge is not complete on sensor & sampling capacitor gpios
    • proposal 1: Increase TSLPRM_DELAY_DISCHARGE_ALL or add a delay between acquisition
  • During normal acquisition, charge/transfer is not complete
    • proposal 1: increase htsc.Init.CTPulseHighLength and htsc.Init.CTPulseLowLength
    • proposal 2: increase htsc.Init.PulseGeneratorPrescaler
    • proposal 3: proposal 1 + proposal 2
  • Reference is not up to date due to PROX mode
    • proposal
      • in tsl_conf.h
        • #define TSLPRM_USE_PROX 0
        • #define TSLPRM_ECS_K_SLOW (10*4)
        • #define TSLPRM_ECS_K_FAST (20*4)
        • #define TSLPRM_ECS_DELAY (500/2)
      • in main.c
 // Get TSC/TSL keys status
 TSL_obj_GroupProcess(&MyObjGroup);
 // Point to first object
 TSL_dxs_FirstObj(&MyObjGroup);
 // Process ECS algo
 if (TSL_tim_CheckDelay_ms(TSLPRM_ECS_DELAY, &ECSLastTick) == TSL_STATUS_OK){
 TSL_ecs_Process(&MyObjGroup);
 }
  • Parasitic capacitance can be linked with gpio alternates modes. Does Delta behavior is observed on all sensors?

Regards.

John_1992
John_1992Author
Associate II
August 27, 2021

Hi Olivier,

Touch setup:

  • 2 simple buttons
  • Sampling cap = 47nF
  • HCLK = 4MHz
  • CTPulseHighLength and CTPulseLowLength are both 10 CLK without clock Prescaler
  • Please check following log. Device would enter stop mode in black box period (Start touch measurement -> Measurement completed -> enter STOP mode -> wake up -> start touch measurement ->...).0693W00000DlO8oQAF.png

Here is my test result:

  1. Increasing TSLPRM_DELAY_DISCHARGE_ALL does not solve this issue (increased from 1000 to 2000).
  2. Increasing charge and discharge cycle does not solve this issue.
  3. PROX mode is disabled.
  4. Delta abnormal behavior is observed on both up and down buttons.

The tricky part is that this would only happen after waking up from STOP mode. My program would make sure the touch measurement is completed before entering STOP mode.

OlivierR
ST Employee
August 27, 2021

John,

It looks like gpio parasitic capacitance is involved when we exit from STOP mode.

Usually Delta bellow 10 can be seen as noise (10% of Max value), Usual Delta value may reach 100..200.

To avoid this behavior I propose to set ECS and reset PROX. Doing this we will be able to adjust Ref on the fly.

In tsl_conf.h:

#define TSLPRM_ECS_K_SLOW (10*4)
#define TSLPRM_ECS_K_FAST (20*4)
#define TSLPRM_ECS_DELAY (500/5) 
#define TSLPRM_USE_PROX (0)

In main.c:

while (1)
 {
 if(TSCAcqDone != 0){
 myLedOn(LEDY);
 TSCAcqDone = 0;
 // Get TSC/TSL keys status
 TSL_obj_GroupProcess(&MyObjGroup);
 // Point to first object
 TSL_dxs_FirstObj(&MyObjGroup);
 // Process ECS algo
 if (TSL_tim_CheckDelay_ms(TSLPRM_ECS_DELAY, &ECSLastTick) == TSL_STATUS_OK){
 TSL_ecs_Process(&MyObjGroup);
 }
 // Application sensor processing
 // Handle Led
 for (IdLed=0; IdLed < TSLPRM_TOTAL_CHANNELS; IdLed++){
 if(TKEY_DET(IdLed)){
 myLedOn(IdLed);
 }
 else if(TKEY_REL(IdLed)){
 myLedOff(IdLed);
 }
 }
 // Restart all bank acquisition
 TSCidxGroup = 0;
 TSCAcqDone = 0;
 // For FTB test, wait for 15ms
 HAL_Delay(STMTBOX_WAIT_FOR_FFTB_TESTS);
 TSL_acq_BankConfig(TSCidxGroup);
 TSL_acq_BankStartAcq_IT();
 myLedOff(LEDY);
 // Handle STOP MODE......
 }else{
 __WFI();
 }
 }

OlivierR
OlivierRBest answer
ST Employee
September 7, 2021

John,

I reproduce and understand this behavior.

  • After a power-up sequence, all peripherals/gpios/Interconnect are in a default state (to simplify).
    • If you start TSC acquisition, Ref&Measure will be compute taking into account all these system setting. Let's call Meas1.
    • If you move to EnterStopMode(), after exiting from STOP mode, all peripherals/gpios/Interconnect system setting are not the same.
    • A new TSC acquisition will give Meas2
  • To avoid this behavior call EnterStopMode() before the first TSC acquisition. Doing this, Mea and Ref will be measure/compute every time in the same system context. Algo can be
    • Power-up
    • Peripherals Init (GPIO, TSC, Sysclk)
    • Label ici
    • EnterStopMode()
    • Start TSC acquisition
    • Wait end of TSC acquisition
    • Call ECS api
    • goto ici

Find attached software example based on DISCO-L053.

Olivier

John_1992
John_1992Author
Associate II
September 8, 2021

Thanks for the solution.