Documente Academic
Documente Profesional
Documente Cultură
HIGHLIGHTS
This section of the manual contains the following topics:
10
WDT and Power
Saving Modes
10.1 Introduction
This section addresses the Watchdog Timer (WDT) and Power Saving modes of the dsPIC30F
device family. The dsPIC DSC devices have two reduced Power modes that can be entered
through execution of the PWRSAV instruction:
• Sleep Mode: The CPU, system clock source, and any peripherals that operate on the
system clock source are disabled. This is the lowest Power mode for the device.
• Idle Mode: The CPU is disabled, but the system clock source continues to operate.
Peripherals continue to operate, but can optionally be disabled.
The WDT, when enabled, operates from the internal LPRC clock source and can be used to
detect system software malfunctions by resetting the device if the WDT has not been cleared in
software. Various WDT time-out periods can be selected using the WDT postscaler. The WDT
can also be used to wake the device from Sleep or Idle mode.
Note: SLEEP_MODE and IDLE_MODE are constants defined in the assembler include
file for the selected device.
The Power Saving modes can be exited as a result of an enabled interrupt, WDT time-out, or a
device Reset. When the device exits one of these two Operating modes, it is said to ‘wake-up’.
The characteristics of the Power Saving modes are described in subsequent sections.
The processor will exit, or ‘wake-up’, from Sleep on one of the following events:
• On any interrupt source that is individually enabled
• On any form of device Reset
• On a WDT time-out
Note: Please refer to the “Electrical Specifications” section of the dsPIC30F device data
sheet for TPOR, TFSCM and TLOCK specification values.
The processor will wake from Idle mode on the following events:
• On any interrupt that is individually enabled.
• On any source of device Reset.
• On a WDT time-out.
Upon wake-up from Idle, the clock is re-applied to the CPU and instruction execution begins
immediately starting with the instruction following the PWRSAV instruction, or the first instruction
in the ISR.
10
WDT and Power
Saving Modes
SWDTEN
Enable WDT FWDTEN
LPRC 2
FWPSA1
Control FWPSA0
CLRWDT Instr.
PWRSAV Instr.
If the FWDTEN device configuration bit is set, then the WDT is always enabled. However, the
WDT can be optionally controlled in the user software when the FWDTEN configuration bit has
been programmed to ‘0’.
The WDT is enabled in software by setting the SWDTEN control bit (RCON<5>). The SWDTEN
control bit is cleared on any device Reset. The software WDT option allows the user to enable
the WDT for critical code segments and disable the WDT during non-critical segments for
maximum power savings.
The WDT has two clock prescalers, Prescaler A and Prescaler B, to allow a wide variety of
time-out periods. Prescaler A can be configured for 1:1, 1:8, 1:64 or 1:512 divide ratios. Prescaler
B can be configured for any divide ratio from 1:1 through 1:16. Time-out periods that range
between 2 ms and 16 seconds (nominal) can be achieved using the prescalers.
The prescaler settings are selected using the FWPSA<1:0> (Prescaler A) and FWPSB<3:0>
(Prescaler B) configuration bits in the FWDT Device Configuration register. The FWPSA<1:0>
and FWPSB<3:0> values are written during device programming. For more information on the
WDT prescaler configuration bits, please refer to Section 24. “Device Configuration”.
The time-out period of the WDT is calculated as follows:
Equation 10-1: WDT Time-out Period
Note: The WDT time-out period is directly related to the frequency of the LPRC oscillator.
The frequency of the LPRC oscillator will vary as a function of device operating
voltage and temperature. Please refer to the specific dsPIC30F device data sheet
for LPRC clock frequency specifications.
10
WDT and Power
Saving Modes
Table 10-2: WDT Time-out Period vs. Prescale A and Prescale B Settings
Note: If a PMD bit is set, the corresponding module is disabled after a delay of 1 instruction
cycle. Similarly, if a PMD bit is cleared, the corresponding module is enabled after a
delay of 1 instruction cycle (assuming the module control registers are already
configured to enable module operation).
Please check individual device data sheet for specific operational details of the PMD register.
10
WDT and Power
Saving Modes
Question 1: The device resets even though I have inserted a CLRWDT instruction in my
main software loop.
Answer: Make sure that the software loop that contains the CLRWDT instruction meets the
minimum specification of the WDT (not the typical value). Also, make sure that interrupt
processing time has been accounted for.
Question 3: How do I tell which peripheral woke the device from Sleep or Idle mode?
Answer: You can poll the IF bits for each enabled interrupt source to determine the source of
wake-up.
Note: Please visit the Microchip web site (www.microchip.com) for additional Application
Notes and code examples for the dsPIC30F Family of devices.
10
WDT and Power
Saving Modes
NOTES:
10
WDT and Power
Saving Modes