cancel
Showing results for 
Search instead for 
Did you mean: 

STM8L050J3 wfe() wakeup using TIM2 timer.

GBran.2
Associate II

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.

4 REPLIES 4
AA1
Senior III

You should post you code.

GBran.2
Associate II

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.2
Associate II

The header file.

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

And maybe it is not stopped in WFE.