Power Control Modes
For bots where power consumption is critical, the bot microcontroller provides power-reduced modes of operation as a standard feature.
The microcontroller has three power-reducing modes: Idle, Sleep and Power-Down. In the Idle Mode (bit IDL is set), the internal oscillator continues to run and the Interrupt, External Port and Timer blocks continue to be clocked, but the clock signal is gated off to the CPU. In Sleep (bit SLP is set) and Power-Down (bit PD is set) modes, the oscillator is frozen. The only difference between Sleep and Power-Down modes are the energy consumed by the microcontroller, the heat it generates and the amount of time it takes for it to restart. The Idle, Sleep and Power-Down modes are activated by setting bits in the Power Control Special Function Register (PCON). The address of this register is 0x0087.
Idle Mode
An instruction that sets the Idle Mode bit (IDL) causes that to be the last instruction executed before going into Idle Mode. In the Idle Mode, the internal clock signal is gated off to the CPU, but not to the Interrupt, Timer and External Port functions. The CPU status is preserved in its entirety: the Stack Pointer (SP), Program Counter (PC), Program Status Word (PSW), Interrupt Status Word (ISW) and all other registers mantain their data during Idle mode. The External Port registers (P0–P7) hold the data they had at the time Idle mode was activated.
There is only one way to terminate Idle Mode: activation of any enabled interrupt will cause the Idle Mode bit (IDL) to be cleared by the microcontroller, terminating the Idle Mode. The interrupt will be serviced, and following RETI the next instruction to be executed will be the one following the instruction that put the bot into Idle Mode.
Sleep Mode
An instruction that sets the Sleep Mode bit (SLP) causes that to be the last instruction executed before going into Sleep Mode. In the Sleep Mode, the on-chip oscillator is frozen. With the clock frozen, all functions are stopped, but the Internal Memory and thus the Special Function Registers are held. The energy consumption and heat generation of the microcontroller is greatly reduced in Sleep Mode. On the other hand, exiting Sleep Mode is not instantaneous, and it will take the microcontroller some time to restart after it exits Sleep Mode.
The only exit from Sleep Mode is for data to be received for External Ports 0 or 1, regardless of an interrupt being enabled or not for either of those External Ports. The data received from the port that terminated the Sleep Mode will not be stored in the corresponding Special Function Register (P0 or P1) and the corresponding Port Received bit (XI0 or XI1) of the External Port Control Register (XCON) will not be set. Thus if an interrupt was enabled for the corresponding External Port it will not be triggered, and the data sent to the port will be lost in any case. The next instruction to be executed will be the one following the instruction that put the bot into Sleep Mode.
Power-Down Mode
An instruction that sets the Power-Down Mode bit (PD) causes that to be the last instruction executed before going into Power-Down Mode. In the Power-Down Mode, the on-chip oscillator is frozen. With the clock frozen, all functions are stopped, but the Internal Memory and thus the Special Function Registers are held. The energy consumption and heat generation of the microcontroller is greatly reduced in Power-Down Mode, even more so than in Sleep Mode. On the other hand, exiting Power-Down Mode is not instantaneous, and it will take the microcontroller some time to restart, much more so than for Sleep Mode.
The only exit from Power-Down Mode is for data to be received for External Ports 0 or 1, regardless of an interrupt being enabled or not for either of those External Ports. The data received from the port that terminated the Power-Down Mode will not be stored in the corresponding Special Function Register (P0 or P1) and the corresponding Port Received bit (XI0 or XI1) of the External Port Control Register (XCON) will not be set. Thus if an interrupt was enabled for the corresponding External Port it will not be triggered, and the data sent to the port will be lost in any case. The next instruction to be executed will be the one following the instruction that put the bot into Power-Down Mode.