How to enter wait mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to enter wait mode

Jump to solution
1,131 Views
pascalschröer
Contributor V

Hi at all,

First of all my facts:

I'm using CW V.1.5 (without PEX), to program a MK20DX128 (50MHz)


Now my Problem:

I develop a battery powered device which runs a lot of time but only works

a few minutes per day. So I would like to force the device into a wait or

sleep mode. The problem is that I need the UART receive interrupt

to wake up the device. I do all my calculations in interrupts, so my main loop

is empty.

At the moment I try to force the device into wait mode immediately

when I arrive the main loop.

for(;;)

    {   

   SCB_SCR &= ~SCB_SCR_SLEEPDEEP_MASK;
   asm("WFI");

    }

How can I check if the device is in wait mode? Is there a special register?

Is there another sleep register which fits to my problem?

Thanks a lot!

Pascal

Labels (1)
Tags (2)
0 Kudos
1 Solution
817 Views
mjbcswitzerland
Specialist V

Pascal

I don't think you need to directly check the mode because you will know when the processor is in the wait mode since it won't be running.

In the uTasker project there is a low power task that manages the use of the mode and it is easy to check whether the processor is running or sleeding by the state of an output or an LED.

extern void fnLowPower(TTASKTABLE *ptrTaskTable)                     // lowpower task called on every scheduling pass

{

if (!uNoSchedule(OWN_TASK)) {                                    // is the scheduler idle?
    MEASURE_LOW_POWER_ON();                                     
    fnDoLowPower();                                              // switch to low power mode until woken
    MEASURE_LOW_POWER_OFF();                                    
}

}

fnDoLowPower() is effectively (in its simplest form) the "WFI" command and MEASURE_LOW_POWER_ON() and MEASURE_LOW_POWER_OFF() are typically defined to set and clear an LED (for example) and it is seen when the processor is in the sleep or the run mode.

The low leakage modes are probably best monitored by measuring the current consumption to ensure that value is as expected since this is the aim of these modes anyway. As well as limits to peripherals operating in each mode there will usally be different start-up times when leaving the used mode, so effects of this on the system operation need to be considered as part of the design/test.

Regards

Mark

View solution in original post

0 Kudos
4 Replies
817 Views
mjbcswitzerland
Specialist V

Pascal

In deep sleep mode most peripheral clocks are stopped and so no UART reception will be possible (to generate an interrupt to wake the processor).

It may be appropriate to use a LLWU pin (connected in parallel with the UART Rx) to allow wakeup from a low leakage mode.

Regards

Mark

0 Kudos
817 Views
pascalschröer
Contributor V

Hey Mark,

Okay that could be a solution. I will try it!

But where can I see in which mode the device currently runs?

I tried to force the device into the wait mode but I can't check it.

I haven't found a register in the datasheet which give information

about this status.

Thanks

Pascal

0 Kudos
818 Views
mjbcswitzerland
Specialist V

Pascal

I don't think you need to directly check the mode because you will know when the processor is in the wait mode since it won't be running.

In the uTasker project there is a low power task that manages the use of the mode and it is easy to check whether the processor is running or sleeding by the state of an output or an LED.

extern void fnLowPower(TTASKTABLE *ptrTaskTable)                     // lowpower task called on every scheduling pass

{

if (!uNoSchedule(OWN_TASK)) {                                    // is the scheduler idle?
    MEASURE_LOW_POWER_ON();                                     
    fnDoLowPower();                                              // switch to low power mode until woken
    MEASURE_LOW_POWER_OFF();                                    
}

}

fnDoLowPower() is effectively (in its simplest form) the "WFI" command and MEASURE_LOW_POWER_ON() and MEASURE_LOW_POWER_OFF() are typically defined to set and clear an LED (for example) and it is seen when the processor is in the sleep or the run mode.

The low leakage modes are probably best monitored by measuring the current consumption to ensure that value is as expected since this is the aim of these modes anyway. As well as limits to peripherals operating in each mode there will usally be different start-up times when leaving the used mode, so effects of this on the system operation need to be considered as part of the design/test.

Regards

Mark

0 Kudos
817 Views
pascalschröer
Contributor V

Hey Mark,

Thanks for your answer!

Pascal

0 Kudos