98
CY8C28xxx PSoC Programmable System-on-Chip TRM, Document No. 001-52594 Rev. *G
Sleep and Watchdog
The reset state of the sleep timer is a count value of all
zeros. There are two ways to reset the sleep timer. Any
hardware reset, (that is, POR, XRES, or Watchdog Reset
(WDR) will reset the sleep timer. There is also a method that
allows the user to reset the sleep timer in firmware. A write
of 38h to the RES_WDT register clears the sleep timer.
Note
Any write to the RES_WDT register also clears the
watchdog timer.
Clearing the sleep timer may be done at anytime to synchro-
nize the sleep timer operation to CPU processing. A good
example of this is after POR. The CPU hold-off, due to volt-
age ramp and others, may be significant. In addition, a sig-
nificant amount of program initialization may be required.
However, the sleep timer starts counting immediately after
POR and will be at an arbitrary count when user code
begins execution. In this case, it may be desirable to clear
the sleep timer before enabling the sleep interrupt initially, to
ensure that the first sleep period is a full interval.
12.2
Application Description
The following are notes regarding sleep as it relates to firm-
ware and application issues.
Note 1
If an interrupt is pending, enabled, and scheduled to
be taken at the instruction boundary after the write to the
sleep bit, the system will not go to sleep. The instruction will
still execute, but it will not be able to set the SLEEP bit in the
CPU_SCR0 register. Instead, the interrupt will be taken and
the effect of the sleep instruction is ignored.
Note 2
The Global Interrupt Enable (CPU_F register) does
not need to be enabled to wake the system out of sleep
state. Individual interrupt enables, as set in the interrupt
mask registers, are sufficient. If the Global Interrupt Enable
is not set, the CPU will not service the ISR associated with
that interrupt. However, the system will wake up and con-
tinue executing instructions from the point at which it went to
sleep. In this case, the user must manually clear the pending
interrupt or subsequently enable the Global Interrupt Enable
bit and let the CPU take the ISR. If a pending interrupt is not
cleared, it will be continuously asserted. Although the sleep
bit may be written and the sleep sequence executed as soon
as the device enters Sleep mode, the Sleep bit is cleared by
the pending interrupt and Sleep mode is exited immediately.
Note 3
On wakeup, the instruction immediately after the
sleep instruction is executed before the interrupt service rou-
tine (if enabled). The instruction after the sleep instruction is
pre-fetched, before the system actually goes to sleep.
Therefore, when an interrupt occurs to wake the system up,
the pre-fetched instruction is executed and then the interrupt
service routine is executed. (If the Global Interrupt Enable is
not set, instruction execution will just continue where it left
off before sleep.)
Note 4
If PLL mode is enabled, CPU frequency must be
reduced to 3 MHz before going to sleep. The PLL will over-
shoot as it attempts to re-lock after wakeup; therefore, the
CPU frequency must be relatively low. It is recommended to
wait 10 ms after wakeup, before normal CPU operating fre-
quency may be restored.
Note 5
Analog power must be turned off by firmware before
going to sleep, to achieve the smallest sleep current. The
system sleep state does not control the analog array. There
are individual power controls for each analog block and
global power controls in the reference block. These power
controls must be manipulated by firmware.
Note 6
If the Global Interrupt Enable bit is disabled, it can be
safely enabled just before the instruction that writes the
sleep bit. It is usually undesirable to get an interrupt on the
instruction boundary, just before writing the sleep bit. This
means that on the return from interrupt, the sleep command
will be executed, possibly bypassing any firmware prepara-
tions that must be made to go to sleep. To prevent this, dis-
able interrupts before preparations are made. After sleep
preparations, enable global interrupts and write the sleep bit
with the two consecutive instructions as follows.
and f,~01h // disable global interrupts
// (prepare for sleep, could
// be many instructions)
or f,01h // enable global interrupts
mov reg[ffh],08h // Set the sleep bit
Due to the timing of the Global Interrupt Enable instruction, it
is not possible for an interrupt to occur immediately after that
instruction. The earliest the interrupt can occur is after the
next instruction (write to the Sleep bit) has been executed.
Therefore, if an interrupt is pending, the sleep instruction is
executed; but as described in Note 1, the sleep instruction
will be ignored. The first instruction executed after the ISR is
the instruction after sleep.
Summary of Contents for CY8C28 series
Page 65: ...64 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G RAM Paging ...
Page 125: ...124 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G ...
Page 311: ...310 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G IDAC_CR0 1 FDh ...
Page 317: ...316 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G ...
Page 393: ...392 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G ...
Page 477: ...476 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G Digital Clocks ...
Page 561: ...560 CY8C28xxx PSoC Programmable System on Chip TRM Document No 001 52594 Rev G ...