MINI MAX low power mode
April 27, 2015 01:48PM
Hi,
I have just taken ownership of a mini max board.

As I am new to the board and to the ByPic software, can someone advise if the ByPic language has any command for putting the PIC micro into a low power sleep mode?

thanks
PP.
Re: MINI MAX low power mode
April 27, 2015 06:19PM
Yes,
the command is powersave(1)

However using this will send the board into sleep mode and the only way to wake it is via reset or some other condition usually using a timer. The best and most power efficient way is to use the watch dog timer. This is done as follows:

// watch dog for power down control
constant WDTCLR         0xBF800004
constant WDTSET         0xBF800008 // wdtcomset
constant WDSW           (1 << 15)
constant WDCLR          1

The above constants point to the the built in watch dog timer which by default is disabled.

@WDTSET = WDSW // turn on watch dog (about 16 sec)

If the timer is turned on and nothing is done about it then in about 16 seconds the processor will reset, try it. To prevent the processor resetting then the timer must be cleared within the 16 second period

@WDTSET = WDCLR // resets watch dog

The idea is to put this in a program loop that, all being well should get called regularly. If not then the program has crashed and the watch dog will restore normality after a short period.

This can be used also for low power to shut down operation for a period of time and wake up for a brief period to do something. A data logger for example could shut down for an hour or so and wake up to write to an SD card then shut down again.

 @WDTSET = WDSW // turn on watch dog (about 16 sec)
 for j = 1 to n
      powersave(1) // sleep mode for CPU (about 15-16 sec)
 next
 @WDTCLR = WDSW // watchdog off

In the above example n is the number of 16 second periods, the watch dog is enabled and then powersave(1) is envoked.
In this instance the watch dog works a bit differently in that the processor will pause at the 'powersave(1)' command. When the watch dog fires some 16 seconds later, instead of resetting the processor it will simply allow the processor to resume and go on to 'next' which will then of course shut down again for a further 16 seconds. It will do this n times so for 2 hours n would be about 450.

An actual example of this is used in the IoT kit code here client where it shouts itself down for 30 seconds. The full IoT kit instructions are here.

It should be possible to get the power to under 1mA, most of the power will be consumed by the regulator. One thing to watch out for is that if anything is connected to a port then it must not inadvertently supply power. This can be found by experimentation as it depends on what it is connected to, sometimes setting the port to an input works, sometimes output.
Sorry, you do not have permission to post/reply in this forum.