wakeup from gpio does not workin deep sleep mode

Bluetooth BLE devices, Bluetooth MESH devices, Bluetooth Beacon devices, Sub-G devices, etc.


Post Reply
percy(unwired)
Posts: 18

Hi

Wakeup from gpio works fine when TUYA_CPU_SLEEP mode is used. However when TUYA_CPU_DEEP_SLEEP mode is used the device does not wakeup from sleep.

the wakeup settings in sdk are as below

// TUYA DEEP SLEEP MODE SETTINGS
tkl_cpu_sleep_mode_set(1, TUYA_CPU_SLEEP);

Code: Select all

       // WAKE UP SOURCE SETTINGS       
        TUYA_WAKEUP_SOURCE_BASE_CFG_T param;

        param.source = TUYA_WAKEUP_SOURCE_GPIO;
        param.wakeup_para.gpio_param.gpio_num = TUYA_GPIO_NUM_12;
        param.wakeup_para.gpio_param.level  = TUYA_GPIO_LEVEL_LOW;
        tkl_wakeup_source_set(&param); 

the low level signal (ground) to TUYA_GPIO_NUM_12 for waking up the cpu is provided by TUYA_GPIO_NUM_16 through a pushbutton.

This works fine in TUYA_CPU_SLEEP mode .

However in TUYA_CPU_DEEP_SLEEP mode the TUYA_GPIO_NUM_16 is no longer able to provide the low level signal as the cpu goes into sleep mode. how do we fix the scenario. no other external connection is available to the wakeup pin.

User avatar
joey_nobug
Posts: 143

Re: wakeup from gpio does not workin deep sleep mode

Can you provide the schematic diagram of this part?
Why use TUYA_GPIO_NUM_16 to provide low-level signal instead of GND?

Talk is cheap, show me the code.
percy(unwired)
Posts: 18

Re: wakeup from gpio does not workin deep sleep mode

chip platform used bt3l . It is a matrix keypad. pressing any button on the keypad should wake up the bt3l module from deep sleep.

Attachments
matrix_keypad_schematic.png
Last edited by percy(unwired) on 2024年 Nov 12日 15:58, edited 1 time in total.
User avatar
joey_nobug
Posts: 143

Re: wakeup from gpio does not workin deep sleep mode

percy(unwired) 2024年 Nov 12日 15:48

chip platform used bt3l . It is a matrix keypad.

OK, I understand your needs. The tlsr825x platform cannot maintain the GPIO level when in deep sleep, but you can configure the pull-down method to keep the GPIO at a low level in deep sleep state.

Code: Select all

    TUYA_GPIO_BASE_CFG_T gpio_cfg = {
        .mode = TUYA_GPIO_PULLDOWN,
        .direct = TUYA_GPIO_OUTPUT,
    };
Talk is cheap, show me the code.
percy(unwired)
Posts: 18

Re: wakeup from gpio does not workin deep sleep mode

changed the output configuration settings as per your suggestion

here is my sleep routine code

VOID sleep_timer1_callback(TIMER_ID timer_id, VOID_T *arg)
{

tal_main_debug("SLEEP MODE");

sleep_mode_on = 1 ;
ZONE_ON = 0 ;
FUNC_ON = 0 ;

tal_gpio_init(KYB_1, &gpio_cfg_output_1); //TUYA_GPIO_NUM_16
tal_gpio_init(KYB_2, &gpio_cfg_output_1); //TUYA_GPIO_NUM_18

tal_gpio_write(KYB_1,TUYA_GPIO_LEVEL_LOW);
tal_gpio_write(KYB_2,TUYA_GPIO_LEVEL_LOW);

//tal_system_sleep(100) ;
tkl_cpu_sleep_mode_set(1, TUYA_CPU_DEEP_SLEEP);
tkl_cpu_allow_sleep();

}

KEYS connected to TUYA_GPIO_NUM_16 are able to wakeup the device from deep sleep . However the keys connected TUYA_GPIO_NUM_18 are unable to wakeup the device. as my code checks if any keys connected to TUYA_GPIO_NUM_16 were presssed to activate the functions on keys connected to TUYA_GPIO_NUM_18.

during deep sleep all variable data is lost as the device restarts . is there a way to prevent the data loss ori just need to save the required data to nvram and retrieve it each time abutton is pressed.

jinyuan
Posts: 79

Re: wakeup from gpio does not workin deep sleep mode

Try Change The GPIO Direct "TUYA_GPIO_OUTPUT " to "TUYA_GPIO_INPUT" Before MCU enter deep sleep, and config gpio pull down to keep low level, pull up to keep high level when MCU deep sleep.

percy(unwired)
Posts: 18

Re: wakeup from gpio does not workin deep sleep mode

Can we resume from deep sleep without losing previous variable data. Else i would need to save data to nvram everytime before deep sleep and copy from nvram on wakeup.

User avatar
joey_nobug
Posts: 143

Re: wakeup from gpio does not workin deep sleep mode

percy(unwired) 2024年 Nov 12日 18:21

Can we resume from deep sleep without losing previous variable data. Else i would need to save data to nvram everytime before deep sleep and copy from nvram on wakeup.

Deep sleep does not support RAM retention. If RAM retention is required, use TUYA_CPU_SLEEP mode.

Talk is cheap, show me the code.
Post Reply