2023-10-19 10:41 PM - last edited on 2023-11-14 08:00 AM by Amel NASRI
Hello dear community.
I am working on a project with a STM32L462CEU6 powered by battery. In this project we are also using TSC. Now I want STM32 to go in sleep or shutdown mode and wakeup when a touch pad has been touched. So the goal is that TSC measures in background and when a certain threshold has been reached it fires a "wakeup interrupt".
I already searched for this use case in internet but I failed to find useful information. Perhaps, someone can help me with some hints or sites where I can find more information. Is that even possible?
Thanks in advance.
Sebastian
2023-10-23 11:23 AM - edited 2023-10-23 11:29 AM
Welcome @schnitzele, to the community!
You can use TSC in Sleep mode, but unfortunately not in Shutdown. You can read about this in the Online Training for the STM32L4 (just search for TSC):
The touch-sensing controller is active in Run, Sleep, Low-power Run and Low-power Sleep modes. This means that charge transfer acquisition can only be performed in these modes.
In all others modes (Stop 0, Stop 1, Stop 2, Standby and Shutdown), the touch-sensing controller is not operational. In Stop modes, the peripheral is frozen but the registers content is kept. In Standby and Shutdown modes, the registers content is lost and the peripheral must be reinitialized.
A brief description of the interrupt possibilities can be found on the pages Interrupts and Low-power modes, a detailed description in RM0394.
The corresponding library can be found in the repository of the STM32L4 at
Middlewares\ST\STM32_TouchSensing_Library
Hope that helps?
Regards
/Peter
2023-10-25 04:19 AM - edited 2023-10-25 04:20 AM
Hello @Peter BENSCH .
Thanks for your reply. So in my understanding after reading the documents it is not possible to go to sleep mode and wakeup only when a touch button has been touched (perhaps after hours or days)? I only have the posibility to go to sleep and wakeup when acquisition is finished or maxcount interrupt has been sent. Is that right?
Best regards
Sebastian
2023-11-02 01:56 AM - edited 2023-11-02 02:06 AM
Hello Schnitzele,
Unfortunately the TSC does not work in shutdown mode. What you can do is perhaps go into stop 2 for let's say 250ms and wakeup do your TSC acquisition with the sleep mode to check if there is actually a touch. If not you go into stop2. I don't know if this suit your application, but this one way to do it. You will have a better current consumption.
Something like this:
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x1f3, RTC_WAKEUPCLOCK_RTCCLK_DIV16,0x0);
while(1){
if(tsl_user_Exec_IT() != TSL_USER_STATUS_BUSY){
// /*Go into stop 2 mode if acquisition done*/
HAL_SuspendTick();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_ResumeTick();
// Restart TSLPRM_TOTAL_BANKS banks acquisition
idx_bank_it = 0;
acq_done_it = 0;
TSL_acq_BankConfig(idx_bank_it);
TSL_acq_BankStartAcq_IT();
}else{
HAL_SuspendTick();
// /* Enter the CPU to SLEEP mode */
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
HAL_ResumeTick();
}
}
Regards,
Stassen
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.