Let's
have a look at how to set each related register and
bit when entering the Wait Mode.
- Setting an Interrupt for Leaving Wait Mode
- Set an interrupt, which is used to place the MCU out of the
Wait Mode. Make sure the priority level set for this interrupt
is higher than the Processor Interrupt Priority Level (IPL).
- Enabling the Interrupt Enable Flag (I Flag)
- Set the Interrupt Enable Flag (I Flag) in the Flag Register
(FLG) to 1 in order to enable all maskable interrupts.
- Removing Protection
- Set the bit for writing-enable to System Clock Control Registers
0 and 1 that is assigned in the Protect Register (address 0000A
)
to 1 in order to remove protection from these two registers.
- Setting the System Clock Control Registers 0 and 1
- Set the operating clock to be used after returning from the Wait Mode. Unless these registers are specifically
modified, BCLK is selected that was being used before entering
the Wait Mode. Set the WAIT Peripheral Function Clock Stop Bit
to 1 in order to turn the peripheral functions off.
- Executing the WAIT Instruction
- Execute the WAIT instruction to place the MCU into the Wait
Mode. The MCU is placed out of the Wait Mode by an interrupt or
hardware reset. After leaving the Wait Mode, the MCU starts operating
with BCLK that was being used before entering the Wait Mode.
|