cancel
Showing results for 
Search instead for 
Did you mean: 

STM32w108 Sleep Modes

jacobb
Associate II
Posted on January 15, 2014 at 03:05

I can't for the life of me figure out how to get the STM32w108 the wake up with the sleep timer. I basically want to wake up every 15ms and run my main loop. My initialization routine is very short. Here it is:

   SLPTMR->CMPAL = 15  //write to the lower register must be first

   SLPTMR->CMPAH = 0x00000000;  //high register must be second; just 0s

   SLPTMR->IER |= (1 << 1);   //enable interrupt on register A compare

   NVIC->ISER[0] |= (1 << 4);  //need to unmask the interrupt at the ARM core level in the NVIC

   PWR->WAKECR1 |= ((1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)); //sets the appropriate wake up sources including on a compare A

   SCB->SCR |= (1 << 2);   //enable deep sleep

   SLPTMR->CR |= (1 << 11);   //enable sleep mode timer; everything must be configured before enabling sleep mode timer

   asm(''nop''); //needed delay

   asm(''nop'');

   asm(''nop'');

   asm(''nop'');

I go to sleep and I'm only able to wake up with a serial interrupt. The timer doesn't wake me up. Any ideas?

Thanks
4 REPLIES 4
chen
Associate II
Posted on January 15, 2014 at 10:15

Hi

Assuming you have set up the Low Power Wake up correctly (sorry but I am not familiar with every STM32 part in the world!).

Have you set up the timer?

Have you set the timer to generate an IRQ?

Does the low power mode allow wake on timer IRQ?

(Some low power modes are restricted on what can cause wake up).

jacobb
Associate II
Posted on January 15, 2014 at 17:02

Well according to the data sheet it looks like i did everything correctly. I set up the sleep timer and enabled it. I set up an interrupt to occur when the sleep timer matches the sleep compare A register. I set up the wake mode correctly i think.

The only thing I can think of is that I'm not going to sleep correctly. I'm just executing a WFI instruction. Do I have to start the sleep timer or something right before I go to sleep?

chen
Associate II
Posted on January 15, 2014 at 17:22

Hi

As I said, I am not familiar with the specific processor you are using.

''I set up the sleep timer and enabled it.''

Is there an actual timer in the Power Control? There is not in the STM32F4 part that I work on.

Do you mean one of the general Timers (Tim1-14)?

''Do I have to start the sleep timer or something right before I go to sleep?''

If it is a general timer - yes you do have to configure and enable them.

The F4 part, can be woken up by one of the general Timers if it is in 'Sleep Mode'

The F4 part is woken up by any interrupt in sleep mode.

''I'm just executing a WFI instruction.''

This sounds like 'Sleep' mode (as oppose to Stop or Standby modes).

jacobb
Associate II
Posted on January 15, 2014 at 18:34

I'm going to go back and try to make the ST sleep libraries for this part work. Thanks though. Apparently there needs to be a bunch of context saving and all sorts of other things going on.