Hardware Reference
In-Depth Information
7.12 Key Wake-Ups
Most embedded products are powered by batteries. In order for batteries to last longer,
most microcontrollers have incorporated power-saving modes such as the wait mode or the
stop mode in the HCS12. Whenever there is no activity from the end user over a period of
time, the application software would put the embedded product in one of the power-saving
modes and reduce the power consumption. Whenever the end user wants to use the prod-
uct, a keystroke would wake up the microcontroller and put the embedded product back to
normal operation mode. As you learned in Chapter 6, both the reset and unmasked inter-
rupts can put the microcontroller back to normal operation mode. However, reset is not
recommended because it will restart the microcontroller, which would delay the response
to the user request. An unmasked interrupt does not have this drawback. All of the HCS12
members have incorporated the key wake-up feature that will issue an interrupt to wake up
the MCU when it is in the stop or wait mode. After the appropriate configuration, an active
edge on these pins will generate an interrupt to the MCU and force the MCU to exit from
the low-power mode.
7.12.1 Key-Wake-Up Registers
As described in Section 7.5.7, Ports H, J, and P have the key-wake-up capability. Each port
has eight associated registers. The Port Pull Device Enable register and the Port Polarity Select
register together allow the user to choose to use either the rising edge or falling edge to wake up
the MCU. The Port Interrupt Enable register and the Port Interrupt Flag register together allow
the user to use key pressing to wake up the MCU.
7.12.2 Key-Wake-Up Initialization
In order to use the HCS12 key-wake-up feature, the user needs to initialize the wake-up
port properly. The procedure for using the key-wake-up feature is as follows:
Step 1
Set the direction of the key-wake-up bits to input by writing zeros to the related Data
Direction register.
Step 2
Select the rising edge or the falling edge of the wake-up pin to interrupt the MCU by
programming the related registers.
Step 3
Write the service routine for the key-wake-up interrupt and initialize the key-wake-up
interrupt vector.
Step 4
Clear any flags that have been set in the Key-Wake-Up Flag register.
Step 5
Enable the key-wake-up bit by setting the appropriate bits in the Wake-Up Interrupt
Enable register.
Step 6
Clear the global interrupt mask (the I bit of the CCR register).
 
Search WWH ::




Custom Search