Skip to main content
Visitor II
April 4, 2023
Question

STM8L050J3 wfe() wakeup using TIM2 timer.

  • April 4, 2023
  • 3 replies
  • 2087 views

Good morning. I've been trying for a while to put the MCU in low power with the wfe() instruction and wake it up with TIME2 but the MCU gets stuck in wfe() and doesn't wake up. With the debugger active it seems to work even if it doesn't respect the times of the TIM2 counter.

Does anyone have an example or a template to study to understand what I'm doing wrong?

Thanks from now to anyone who can help me.

    This topic has been closed for replies.

    3 replies

    Visitor II
    April 5, 2023

    You should post you code.

    GBran.2Author
    Visitor II
    April 5, 2023

    Ok. My source is test.c with stm8s_base.h header file.

    Isa very sample: In the main() loop i'm call the DoSleepSortTime() function that prepare the cpu to enter in sleep mode (wfe).

    The wfe() function is reallocated in ram so i can disable also the flash avoid more consuption.

    The header file contain the IO and REGISTER definition.

    The program work when i'm in debug mode (with probe connected and ST Visual develop running in debug mode). The myWorkLoop() function are executed every main loop.

    When i disconnect the probe and powering my hardware separately (build on STM8-SO8-DISCO), it's run, execute one main loop (execute the myWorkLoop() function) then stop infinitely.

    It seem that the cpu remaining in the wfe state..

    What happen?

    GBran.2Author
    Visitor II
    April 5, 2023

    The header file.

    Visitor II
    April 6, 2023

    Remove code execution from RAM, regulator off, Flash, etc., and try.

    And maybe it is not stopped in WFE.