Positron Compiler Documentation

Sleep

Source: Positron16 Compiler User Manual, PDF page 359

Syntax

Sleep { Length }

Overview

Places the microcontroller into low power mode for approx n seconds.

Parameters

Length is an optional variable or constant (1-16383) that specifies the duration of sleep in approximate seconds. If length is omitted, then the Sleep command is assumed to be the assembler mnemonic, which means the microcontroller will sleep continuously, or until an internal or external influence wakes it up.

Example

Symbol MyLED = PORTA.0
Do
  PinHigh MyLED
                      ' Turn LED on.
  DelayMs 1000
                      ' Wait 1 second.
  PinLow MyLED
                      ' Turn LED off.
  Sleep 60
                      ' Sleep for 1 minute.
Loop

Notes.

Sleep will place the device into a low power mode for the specified period of seconds. Period is 14-bits, so delays of up to 16383 seconds are the limit. Sleep uses the Watchdog Timer so it is independent of the oscillator frequency.

The Sleep command is used to put the microcontroller in a low power mode without resetting the registers. Allowing continual program execution upon waking up from the Sleep period.

The watchdog must be enabled an set to a postscaler value of 1:256 for sleep to work correctly.