Low Power Modes with Periodic/Real-time Clock Wake-up

XC800 Family
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up
in XC82x/XC83x
Application Note
V1.1, 2010-08
Microcontrollers
Edition 2010-08
Published by
Infineon Technologies AG
81726 Munich, Germany
© 2010 Infineon Technologies AG
All Rights Reserved.
LEGAL DISCLAIMER
THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION
OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY
DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE
INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY
ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY
DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT
LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY
THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE.
Information
For further information on technology, delivery terms and conditions and prices, please contact the nearest
Infineon Technologies Office (www.infineon.com).
Warnings
Due to technical requirements, components may contain dangerous substances. For information on the types in
question, please contact the nearest Infineon Technologies Office.
Infineon Technologies components may be used in life-support devices or systems only with the express written
approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure
of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support
devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain
and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may
be endangered.
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
XC82x/XC83x
Revision History: V1.1 2010-08
Previous Version(s): V1.0
Page
Subjects (major changes since last revision)
Page 5
An overview of the power saving modes in XC83x has been added in Chapter 2.
Page 8
Added a description of the loss of external oscillation wake-up flag that are used in XC83x.
Page 9
Added a description on the considerations during waking up from all power down modes in XC82x
and XC83x.
Page 9
Update Chapter 3.1 to include the usage of XC83x power down mode 1.
Page 10
Page 12
Added Chapter 3.2 and 3.3 on the usage of XC83x power down mode 2 and 3.
Page 13
Added a description of the XC83x power down mode 4 in Chapter 3.4. This mode has the same
behaviors as XC82x power down mode 2.
Page 13
WDT must be disabled before entering XC82x power down mode 2 or XC83x power down mode
4 because a timer overflows in power down mode would prevent the microcontroller from waking
up.
Page 15
Two C codes (XC82x_example and XC83x_example) have been added in Chapter 4. The
assembly code found in the previous version (V1.0) has similiar behaviors as the
XC82x_example and it can also be used to illustrate the usage of XC82x power down mode 2.
We Listen to Your Comments
Is there any information in this document that you feel is wrong, unclear or missing? Your feedback will help us to
continuously improve the quality of this document. Please send your proposal (including a reference to this document) to:
[email protected]
Application Note
3
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
Table of Contents
1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2
2.1
2.2
Overview: Power management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Idle Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Power Down Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3
3.1
3.2
3.3
3.4
Using Power Down Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Using Power Down Mode 1 In XC82x/XC83x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Using Power Down Mode 2 In XC83x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Using Power Down Mode 3 In XC83x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Using Power Down Mode 4 In XC83x and Power Down Mode 2 In XC82x . . . . . . . . . . . . . . . . . . . . 13
4
Demonstration Software: Wake-up from Power Down Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Application Note
4
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
1
Introduction
Dynamically changing the microcontroller operating mode is one way to achieve the lowest average power
consumption. For example, when the microcontroller needs to perform a computationally intensive task, the
microcontroller can run as fast as possible for the shortest possible time. When there are no tasks to perform, a
low current consumption power down mode can be entered, where as much of the microcontroller as possible is
switched off.
Based on this approach, the XC82x/XC83x 8-bit microcontroller has additional built-in power saving modes, such
as power down mode with periodic wake-up or real-time clock wake-up functions, to help achieve the lowest
possible power consumption. These features provide flexibility for the user and offer ideal control for many
applications especially sensor and fail safe applications.
This Application Note provides guidelines and information for the use and setup of the available power down
modes. Two examples are also included. One example is used to illustrate the power down mode with periodic
wake-up function in the XC82x, while a second example illustrates the power down with real-time clock wake-up
function in the XC83x.
2
Overview: Power management
After reset, the active operating mode (normal operating mode) is entered in which the CPU is active and running
in the system clock frequency of either 8 MHz or 24 MHz. From active mode, different power saving modes can
be selected by software. They are:
•
•
•
•
•
Idle mode (XC82x and XC83x)
Power down mode 1 (XC82x and XC83x)
Power down mode 2 (XC82x and XC83x)
Power down mode 3 (XC83x)
Power down mode 4 (XC83x)
Once the microcontroller wakes-up (exits) from these modes, it returns to active mode.
2.1
Idle Mode
The idle mode is used to reduce power consumption by stopping the CPU’s clock. Oscillators and enabled
peripherals remain functional. Refer to the User’s Manual for more details of this mode.
2.2
Power Down Mode
In order to achieve different levels of operation that reduce power consumption, the XC82x has built-in two types
of power down mode, while the XC83x has four power down modes.
In these modes, most of the modules are disabled and powered down while the contents of the on-chip memories
are maintained. Table 1 and Table 2 show the modules that are still running during power down mode in XC82x
and XC83x respectively. Modules which are not referenced in the table are not active in these modes.
Table 1
XC82x Module Behavior in Power Down Mode
Modules
Power Down Mode 1
Power Down Mode 2
Low Power Embedded Voltage Regulator
Running
Running
Real Time Clock
Shut down
Running in RTC Mode 1
75 kHz On-chip Oscillator
Shut down
Running
Application Note
5
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
Table 2
XC83x Module Behavior in Power Down Mode
Modules
Power Down
Mode 1
Power Down
Mode 2
Power Down
Mode 3
Power Down
Mode 4
Low Power Embedded Voltage Regulator
Running
Running
Running
Running
Real Time Clock
Shut down
Running in
RTC Mode 0
Running in
RTC Mode 0
Running in
RTC Mode 1
32.768 kHz Oscillator Pad
Shut down
Running
Running
Shut down
32.768 kHz Oscillator Watchdog
Shut down
Running
Shut down
Shut down
75 kHz On-chip Oscillator
Shut down
Running
Shut down
Running
The only current consumption in power down mode 1 is from the Low Power Embedded Voltage Regulator
(LPEVR). The LPEVR is required to maintain memory contents and to facilitate a fast wake-up from power down
to active mode.
In power down modes 2, 3 and 4, the Real-Time Clock (RTC) and RTC clock source will also be running in addition
to the LPEVR. The RTC has 2 operating modes:
•
•
RTC mode 0 uses the 32.768 kHz external oscillator via the oscillator pad
RTC mode 1 uses the 75 kHz internal oscillator clock as the RTC clock input
Both RTC modes are available in the XC83x, but mode 0 is not available on the XC82x because it does not support
the 32.768 kHz external oscillation.
The power down mode and RTC mode must be enabled and configured to the respective mode (see Table 1 for
XC82x and Table 2 for XC83x) before entering power down mode. Note that in order to detect the failure of the
32.768 kHz external clock in the XC83x, an oscillator watchdog operating with a 75 kHz internal clock must be set
up to run in the XC83x power-down mode 2.
Note: A failure in 32.768 kHz external oscillator is detected when it is running below 16 kHz (typical).
Wake-up Modes
In XC82x/XC83x, there are 2 types of wake-up from each power down mode:
•
•
Wake-up with reset
Wake-up without reset
When wake-up with reset is selected, the system will execute a reset sequence similar to the power-on reset
sequence. The CPU starts running code from the beginning of the Flash code memory. This mode is useful when
the user wants a defined state for all the registers and modules in the microcontroller after wake-up.
When wake-up without reset is selected, a fast wake-up sequence is implemented, which means that the CPU
program counter will continue to run from the point at which it was stopped.
Wake-up Sources
To wake-up from power down mode, one or more sources are available for each power down mode as shown in
Table 3 for XC82x and Table 4 for XC83x.
In power down mode 1, wake-up can only be triggered by toggling the external interrupt 0 pin. For the rest of the
power down mode, RTC is running using either the 32.768 kHz external oscillator or the 75 kHz internal oscillator,
so wake-up can also be triggered when the RTC counter reaches a predefined time. It allows the microcontroller
to exit power down mode and enter active mode after a specific period of time. With this function, dynamically
changing the operating mode of the microcontroller can be achieved with minimum software setup.
There are 2 types of wake-up sources generated from the RTC module:
•
•
Periodic wake-up
Real-time clock (RTC) wake-up
Application Note
6
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
Both wake-up sources are available in XC83x, as shown in Table 4.
The XC83x power down modes 2 and 3 support a real-time clock wake-up function with the RTC running in mode
0. The periodic wake-up function is available in the XC83x power down mode 4.
In XC82x, the real-time clock wake-up is not available (see Table 3). However, the periodic wake-up function is
available in power down mode 2 with the RTC running in mode 1.
The XC82x power down mode 2 and the XC83x power down mode 4 have the same behavior.
Table 3
Available Wake-up Sources for Power Down Mode in XC82x
Wake-up Sources
Periodic wake-up
Power Down Mode 1
Power Down Mode 2
Not available
Available1)
EXINT0
Available
Available
1) This wake-up source will not be available if the RTC clock stops runnning.
Table 4
Available Wake-up Sources for Power Down Mode in XC83x
Wake-up Sources
Power Down
Mode 1
Power Down
Mode 2
Power Down
Mode 3
Power Down
Mode 4
Periodic wake-up
Not available
Not available
Not available
Available1)
Real-time Clock wake-up
Not available
Available1)
Available1)
Not available
32.678 kHz Clock failure
Not available
Available
Not available
Not Available
EXINT0
Available
Available
Available
Available
1) This wake-up source will not be available if the RTC clock stops runnning.
Besides the EXINT0 and RTC wake-up sources, XC83x power down mode 2 has an additional wake-up source
as shown in Table 4. A clock failure in the 32.768 kHz external clock will trigger the microcontroller to wake-up
from power down mode 2. This can be seen as an advantage compared to the power down mode 3. If there is a
clock failure in power down mode 3, the RTC wake-up source is not available and so the microcontroller can only
be woken up by an external trigger EXINT0.
Comparison between Power Down Modes
The XC83x current consumption in power down modes 2, 3 and 4, is approximately 2 uA - 3 uA (typically) higher
than power down mode 1, because more built-in modes are running to support the real-time clock and periodic
wake-up functions.
Similarly, the XC82x power down mode 2 is approximately 2 uA higher than power down mode 1.
While the current consumption of the XC83x power down modes 3 and 4 are quite similar, power down mode 2
has the highest current consumption in that microcontroller.
The main advantage of power down modes 2, 3 and 4 is that the length of time that the microcontroller stays in
power down mode can be easily configured to achieve the required average power consumption.
A feature of the XC83x power down mode 2 is the additionally enabled oscillator watchdog that is used to wakeup the microcontroller when there is a 32.768 clock failure. If the application is able to take the additional 1 uA 2 uA (typicial) current, this is a preferred power down mode, as compared to the mode 3.
Refer to the Data Sheet and AP08101 for more information on power down current.
Application Note
7
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
3
Using Power Down Mode
To enter power down mode, follow the steps listed here. Settings for the specific power down modes are given in
Section 3.1, Section 3.2, Section 3.3 and Section 3.4.
•
•
•
•
Configure wake-up source. Refer to Section 3.1, Section 3.2, Section 3.3 and Section 3.4.
Select the type of power down mode.
Select wake-up mode with reset or without reset.
Enable power down mode.
General code execution sequence for power down mode entry:
MOV
ORL
ORL
MOV
ORL
MOV
SCU_PAGE,#0x01
PMCON0,#0x04
PMCON0,#0x10
PASSWD,#0x98
PMCON0,#0x02
PASSWD,#0xA8
;select PD mode 2
;wake-up with reset mode is selected
;open protection, PD bit is a protected bit
;Power Down Mode Enable.
;close protection
Pin Status In Power Down Mode
In power down mode, pin handling is transparent to the user. All port pins are disabled, except for the external
interrupt 0 pin if it is enabled as a wake-up source. Each port signal that goes into the microcontroller will be held
at the last state when the power down mode was activated. If the user intends to maintain a level of “1” or “0” on
the output pin during power down, the internal pull-up/pull-down device should be enabled before entering power
down mode. Upon wake-up, the port pins will be enabled as per the SFR setting.
Flash Handling In Power Down Mode
Flash memory is shut down in power down mode regardless of the current flash activity; i.e program/erase
operation. It is therefore recommended to ensure that all flash program or erase operations are completed before
entering the power down mode. For a situation where power down mode must be entered immediately, it is
recommended to repeat the previous flash operation after waking-up from power down mode.
Wake-up Flags
When a wake-up from power down mode without reset is selected, the status flag of the wake-up event can be
used to indicate the wake-up source.
•
•
•
wake-up by RTC, bit RTC_RTCON.CFRTC is set to 1
wake-up by external interrupt 0, bit CFRTC is 0
wake-up by loss of external 32.768kHz oscillation, OSC_CON.XTAL2 flag is set to 1
Note that interrupt servicing of the wake-up event is not supported.
Checking of the status bit is useful when an application needs to perform a different task for each source of wakeup.
The status wake-up indication bit RSTCON.WKRS, is used to indicate that the microcontroller has exited to active
mode from the power down state. In addition, this bit can also be used to distinguish between a wake-up with reset
from power down mode and other type of resets; i.e. power on reset (POR). In the wake-up with reset mode, all
registers are reset to default values after wake-up except for this bit. Wake-up flags are listed in Table 5.
Table 5
Wake-up Flags with Different Wake-up Sources
Wake-up sources
RST_RTCON.CFRTC
OSC_CON.XTAL2L
RSTCON.WKRS
EXINT0
0
0
1 (with or without reset)
RTC
1
0
1 (with or without reset)
Loss of External Oscillation 0
1
1 (with or without reset)
Application Note
8
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
Considerations On Waking Up From Power Down Mode
On waking up from power down mode without reset, the CPU starts to run from the instruction following the one
that sets the PD bit. User code must include two NOP instructions immediately after the instructions that sets the
PD bit. This ensures that the first instruction (after the two NOP instructions) is executed correctly after wake-up
from power down mode.
Another consideration is to give at least 500 usec between the time that bit PMCON0.PD is set, to the triggering
of the wake-up. A shorter time will not result in any saving in power consumption because this is the amount of
time needed to shut down all the unused modules.
3.1
Using Power Down Mode 1 In XC82x/XC83x
To enter power down mode 1, the following sequence is recommended:
•
•
•
•
Disable the WDT module (optional).
Disable the RTC module (optional).
Configure wake-up source external interrupt 0, including the selection of external interrupt 0 input pin and
external interrupt 0 trigger select.
Select power down mode 1 where all modules are powered down including the 48 MHz and 75 kHz oscillators.
Considerations When Entering Power Down Mode 1 In XC82x/XC83x
In power down mode 1, the shutting down of the 75 kHz oscillator causes the RTC and Watchdog Timer (WDT)
module which uses this oscillator to clock their respective counter/timer to stop running. If the user intends to use
these 2 modules after the microcontroller wakes-up without a reset, it is recommended to disable the RTC and
WDT module by software before entering power down mode and only to enable them again after exiting from
power down mode. This is to avoid any inaccurate counting because the 75 kHz oscillator usually starts to run with
an inaccurate frequency on waking up.
Considerations On Waking up from Power Down Mode 1 In XC82x/XC83x
After wake-up from power down mode without reset, ensure that the 48 MHz and 75 kHz oscillators are stable after
power up by checking the status of the OSC_CON.INTOSC_ST status flag. It is recommended to enable the WDT
and RTC module only after this bit is set to 1B. In addition, the oscillator watchdog which monitors the behavior of
these 2 oscillators can also be re-enabled by setting bit OSC_CON.RCOWDRST.
Demonstration Code
Example for power down mode 1 entry and exit:
;Disable WDT
MOV
SCU_PAGE,#0x01
MOV
PASSWD,#0x98 ;open protection, WDTEN is a protected bit
ANL
WDTCON,#0xFB
MOV
PASSWD,#0xA8 ;close protection
;Disable RTC
ANL
RTC_RTCON, #0xFE
;Configure external interrupt 0 as wake-up event
;P0.5 pin is the default external interrupt 0
MOV
SCU_PAGE, #0x01 ;enable external interrupt 0 wake-up resource
ANL
PMCON0,
#0xFE
ORL
PMCON0,
#0x01 ;set bit EWS to 1
MOV
SCU_PAGE, #0x00
ANL
EXICON0, #0xFC
ORL
EXICON0, #0x01 ;set rising edge to trigger external interrupt 0
;Select power down mode 1
Application Note
9
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
MOV
SCU_PAGE,#0x01
ANL
PMCON0,#0xFB
;select PD mode 1
;Enable power down mode
MOV
PASSWD,#0x98
;open protection, PD bit is a protected bit
ORL
PMCON0,#0x02
;Power Down Mode Enable.
NOP
;2 NOPs are required after setting PD 1 when wake-up without reset
NOP
MOV
PASSWD,#0xA8
;close protection
3.2
Using Power Down Mode 2 In XC83x
The sequence to enter power down mode 2 is:
•
•
•
•
•
•
•
•
•
Power up the 32.768 kHz oscillator pad.
Wait for 2 seconds for the oscillation to be stable.
Ensure that the 75 kHz oscillator is stabled before enabling the 32.768 kHz OWD.
Restart the 32.768 kHz OWD.
When bit XTAL2L is 0, select the RTC Mode 0.
Configure and enable the RTC.
Disable the WDT module.
Select power down mode 2.
Enter power down mode.
Considerations When Entering Power Down Mode 2 In XC83x
The RTC, 75 kHz oscillator and 32.768 kHz oscillator pad are not shut down in power down mode 2. The
Watchdog Timer(WDT), which is clocked by the 75 kHz oscillator, will also be running if it was enabled before
entering this mode. Because the microcontroller will not be able to wake-up and return to active mode when the
Watchdog Timer overflows in power down mode, it is mandatory to disable the WDT before the entry to power
down mode 2. The RTC must be programmed to run in Mode 0; i.e. it must be in time keeping mode before the
entry to power down mode 2. In this RTC mode the real-time clock operates with the 32.768 kHz oscillator input
and the real-time count is maintained. The RTC is not reset and continues to run when the RTC triggers a wakeup from power down mode 2.
To wake-up from power down mode without reset using the RTC wake-up event, register RTCCRx must be setup
before entering power down mode. If the RTC is required to wake-up the microcontroller from power down mode
2, the following RTC configuration should be executed before setting the microcontroller to that mode:
•
•
•
•
Set RTC to mode 0.
Set RTC starting value.
Set compare/capture register RTCCR0 - RTCCR3 value to define the time period after which the
microcontroller should be woken-up from power down mode 2.
Enable RTC.
It is possible to monitor the status of the external oscillation in power down mode 2, as the 32.768 kHz Oscillator
Watchdog (OWD) is enabled in power down mode 2.
Although the 75 kHz oscillator is also running in power down mode 2, it is not possible to monitor the oscillation
because its Watchdog is powered down.
Considerations On Waking up from Power Down Mode 2 In XC83x
To exit power down mode 2, besides the real-time clock wake up event, it is also possible to exit on receipt of an
external wake-up signal via EXINT0 pin if EWS bit is set to 1B in PMCON0 register. In the event of the loss of
external 32.768kHz oscillation, power down mode 2 will be exited when the OSC_CON.XTAL2L flag is set to 1.
Application Note
10
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
In addition, after wake-up from power down mode without reset, the WDT module and oscillator watchdog can be
re-enabled if necessary as explained in Considerations On Waking up from Power Down Mode 1 In
XC82x/XC83x.
Demonstration Code
Example for XC83x power down mode 2 entry and exit:
;enable 32.768kHz oscillator and OWD
MOV
SCU_PAGE, #0x01
ANL
OSC_CON, #0xDF
WAIT_75_STABLE:
MOV
A, OSC_CON
JNB
ACC.6, WAIT_75_STABLE
ORL
OSC_CON, #0x08
WAIT_32_STABLE:
MOV
A, OSC_CON
JB
ACC.4, WAIT_32_STABLE
;RTC configuration
ANL
RTC_RTCON, #0xF9 ;select RTC mode 0
;configure RTC count clock register CNT0~3,
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;Register RTC_CNTx are protected, open protection
MOV
RTC_CNT0,#0x00 ;set the RTC start value
MOV
RTC_CNT1,#0x00
MOV
RTC_CNT2,#0x00
MOV
RTC_CNT3,#0x00
MOV
PASSWD,#0xA8 ;close protection
;configure RTC compare/capture register value
MOV
RTC_RTCCR0,#0x00
MOV
RTC_RTCCR1,#0x06
MOV
RTC_RTCCR2,#0x00
MOV
RTC_RTCCR3,#0x00
;enable RTC
ORL
RTC_RTCON, #0x01 ;start RTC operation
;disable WDT
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;open protection
ANL
WDTCON,#0xFB
MOV
PASSWD,#0xA8 ;close protection
;set microcontroller to PD mode 2
MOV
SCU_PAGE, #0x01
ANL
PMCON0, #0xF3
ORL
PMCON0, #0x04 ;select PD2
MOV
PASSWD,#0x98 ;open protection
ORL
PMCON0,#0x02 ;Power Down Mode Enable.
NOP
;2 NOPs are required after setting PD 2 when wake-up without reset
NOP
MOV
PASSWD,#0xA8 ;close protection
Application Note
11
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
3.3
Using Power Down Mode 3 In XC83x
The sequence to enter power down mode 3 is:
•
•
•
•
•
•
•
Power up the 32.768 kHz oscillator pad.
Wait for 2 seconds for the oscillation to be stable.
Select the RTC Mode 0.
Configure and enable the RTC.
Disable the WDT module (optional).
Select power down mode 3.
Enter power down mode.
Considerations When Entering Power Down Mode 3 In
XC83x
As with power down mode 1, shutting down the 75 kHz oscillator causes the Watchdog Timer (WDT) module to
stop running in power down mode 3. Considerations for WDT during power down mode are described in
Considerations When Entering Power Down Mode 1 In XC82x/XC83x.
In power down mode 3, the RTC and 32.768 kHz oscillator pad are not powered down. However, no monitoring
of the status of the external oscillation is possible in this mode. In the event of the loss of the external OSC, the
RTC will not be able to wake up the microcontroller from power down mode 3. It is therefore recommended to
enable the external interrupt wake-up resource before entering power down mode 3.
As for the RTC, it must be programmed to run in RTC Mode 0. Considerations When Entering Power Down
Mode 2 In XC83x describes the setup of RTC for power down mode 3.
Considerations On Waking up from Power Down Mode 3
To exit power down mode 3, the real-time clock wake-up event can be used if the external oscillation is stable. It
can also be woken when it receives an external wake-up signal via the EXINT0 pin, by setting the EWS bit to 1B
in the PMCON0 register.
The use of WDT after wake up without reset from power down mode 3 is described in Considerations On Waking
up from Power Down Mode 1 In XC82x/XC83x.
Demonstration Code
Example for XC83x power down mode 3 entry and exit:
;enable 32.768kHz oscillator
MOV
SCU_PAGE, #0x01
ANL
OSC_CON, #0xDF
WAIT_32_STABLE:
MOV
A, OSC_CON
JB
ACC.4, WAIT_32_STABLE
;RTC configuration
ANL
RTC_RTCON, #0xF9 ;select RTC mode 0
;configure RTC count clock register CNT0~3,
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;Register RTC_CNTx are protected, open protection
MOV
RTC_CNT0,#0x00 ;set the RTC start value
MOV
RTC_CNT1,#0x00
MOV
RTC_CNT2,#0x00
MOV
RTC_CNT3,#0x00
MOV
PASSWD,#0xA8 ;close protection
;configure RTC compare/capture register value
MOV
RTC_RTCCR0,#0x00
MOV
RTC_RTCCR1,#0x06
Application Note
12
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
MOV
MOV
;enable RTC
ORL
RTC_RTCCR2,#0x00
RTC_RTCCR3,#0x00
RTC_RTCON, #0x01 ;start RTC operation
;disable WDT
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;open protection
ANL
WDTCON,#0xFB
MOV
PASSWD,#0xA8 ;close protection
;set microcontroller to PD mode 3
MOV
SCU_PAGE, #0x01
ANL
PMCON0, #0xF3
ORL
PMCON0, #0x08 ;select PD3
MOV
PASSWD,#0x98 ;open protection
ORL
PMCON0,#0x02 ;Power Down Mode Enable.
NOP
;2 NOPs are required after setting PD 3 when wake-up without reset
NOP
MOV
PASSWD,#0xA8 ;close protection
3.4
Using Power Down Mode 4 In XC83x and Power Down Mode 2 In XC82x
The sequence to enter XC83x power down mode 4 or XC82x power down mode 2 is:
•
•
•
•
Configure and enable RTC.
Disable the WDT module.
Select XC83x power down mode 4 or XC82x power down mode 2.
Enable power down mode.
Considerations When Entering Power Down Mode 4 In XC83x or Power Down Mode 2 In XC82x
In both modes, the RTC and 75 kHz oscillator are not powered down. The Watchdog Timer(WDT), clocked by the
75 kHz oscillator, will also be running if it was enabled before entering this mode. As the microcontroller will not
be able to wake-up and return to active mode when the watchdog timer overflows, it is mandatory to disable the
WDT before entering these two power down modes. As for the RTC, it must be programmed to run in RTC Mode
1: Periodic Wake-up Mode, before the entry to power down. In this RTC mode, the real-time clock operates with
the 75 kHz oscillator running in the periodic wake-up mode and the real-time count is maintained. The RTC
counter is reset and the count starts from zero every time the RTC triggers a wake-up from power down mode.
Considerations When Entering Power Down Mode 2 In XC83x describes the RTC setup, except the RTC must
be set to mode 1 instead of mode 0 before entering these two modes.
The calculation for periodic wake-up time setup is:
(1)
CCVAL – CNTVAL ) × 512t wake – up = (------------------------------------------------------------------------75000
where
•
•
CNTVAL : Counter values in CNTx registers
CCVAL : Compare values in RTCCRx registers
Although the 75 kHz oscillator is running in these two power down modes, it is not possible to monitor the status
of the 75 kHz oscillation because the oscillator watchdog is powered down.
Application Note
13
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
Considerations On Waking up from Power Down Mode 4 In XC83x or Power Down Mode 2 In XC82x
Besides the real-time clock wake up event, the microcontroller can also be woken on receipt of external wake-up
signal via the EXINT0 pin, by setting the EWS bit to 1B in the PMCON0 register.
After wake-up from power down mode without reset, the WDT module and Oscillator Watchdog(WDT) can be reenabled if necessary, as explained in Considerations On Waking up from Power Down Mode 1 In
XC82x/XC83x. For subsequent entry to the XC82x power down mode 2, or the XC83x power down mode 4, the
RTC does not require setup again if the time planned to stay in power down and active mode remains the same.
Demonstration Code
Example for XC82x power down mode 2 entry and exit:
;RTC configuration
ORL
RTC_RTCON, #0x04 ;select RTC mode 1
;configure RTC count clock register CNT0~3,
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;Register RTC_CNTx are protected, open protection
MOV
RTC_CNT0,#0x00 ;set the RTC start value
MOV
RTC_CNT1,#0x00
MOV
RTC_CNT2,#0x00
MOV
RTC_CNT3,#0x00
MOV
PASSWD,#0xA8 ;close protection
;configure RTC compare/capture register value
MOV
RTC_RTCCR0,#0x00
MOV
RTC_RTCCR1,#0x06
MOV
RTC_RTCCR2,#0x00
MOV
RTC_RTCCR3,#0x00
;enable RTC
ORL
RTC_RTCON, #0x01 ;start RTC operation
;disable WDT
MOV
SCU_PAGE, #0x01
MOV
PASSWD,#0x98 ;open protection
ANL
WDTCON,#0xFB
MOV
PASSWD,#0xA8 ;close protection
;set microcontroller to PD mode 2
MOV
SCU_PAGE, #0x01
ANL
PMCON0, #0xF3
ORL
PMCON0, #0x04 ;select PD2
MOV
PASSWD,#0x98 ;open protection
ORL
PMCON0,#0x02 ;Power Down Mode Enable.
NOP
;2 NOPs are required after setting PD 2 when wake-up without reset
NOP
MOV
PASSWD,#0xA8 ;close protection
For XC83x power down mode 4, the example code above can be reused. The only difference is to set
PMCON0.PDMODE to 11B.
Application Note
14
V1.1, 2010-08
AP08098
Low Power Modes with Periodic/Real-time Clock Wake-up in
XC82x/XC83x
4
Demonstration Software: Wake-up from Power Down Mode 2
Two sets of example code are provided with this application note. The XC82x_example self-extracting EXE file
demonstrates waking the microcontroller from power down mode 2 using the periodic wake-up function.
The XC83x_example.exe demonstrates waking the microcontroller from power down mode 2 using the real-time
clock wake-up function. A 32.768 kHz clock failure event or external interrupt event will also wake-up the
microcontroller.
The application examples are implemented and verified using the following hardware and software components:
•
•
•
•
XC82x/XC83x easy kit boards.
Infineon DAvE tool for code generation.
DAvE-Bench for code compilation
Infineon XC800_FLOAD for code downloading.
In XC82x_example, output “1” of P1.2 indicates that the microcontroller is in active mode. The microcontroller
wakes up every 10 seconds using the periodic wake-up function, and enters power down mode again after 500 us.
In XC83x_example, output “1” of P1.5 indicates that the microcontroller is in active mode. The microcontroller
wakes up every 4 seconds using the real-time clock wake-up function, and enters power down mode again after
500 us. The microcontroller is also configured to wake up by a rising edge on P0.5, or by a failure in the 32.768 kHz
external oscillator.
Application Note
15
V1.1, 2010-08
w w w . i n f i n e o n . c o m
Published by Infineon Technologies AG