ATD and WAIT
I have some problems with the ATD.
I'm programming on the Metrowerks IDE, and I'm trying to input an
ATD input but something goes wrong...
If someone can give me the typical configuration for the registers it
would be great. Secondly, I would like to put the controller in a wait
mode in order to consume less power, when it does nothing.
How do I do so, and how do I return from the wait mode to the normal
mode. Thanks a bunch, Amir Klein.
Regarding your second question:
To start the WAIT mode you need the CPU needs to execute the WAI assembly
Leaving WAIT power down, is done either using interrupt, or by issuing a
Reset. An interrupt resumes normal code execution after the interrupt
service routine is processed. A Reset initializes the CPU to the Reset
state - as Reset normally does.
Hope this helps,
HC12 In-Circuit Emulators
At 21:55 19/12/2005 +0000, you wrote:
>I have some problems with the ATD.
>I'm programming on the Metrowerks IDE, and I'm trying to input an
>ATD input but something goes wrong...
>If someone can give me the typical configuration for the registers it
>would be great. Secondly, I would like to put the controller in a wait
>mode in order to consume less power, when it does nothing.
>How do I do so, and how do I return from the wait mode to the normal
>mode. Thanks a bunch, Amir Klein.
Entering low power mode can be tricky. What you need to look out for
is the scenario where an interrupt happens right before the wait
instruction. In that scenario, the system handles the interrupt and
then goes into wait. This can be a serious problem if that interrupt
was meant to wake the system. Follow these steps to prevent that
Firstly disable all interrupts:
Then setup whatever it is you want to have wake you up (such as key
wakeup, SCI, RTI interrupts etc). If you are getting woken by the
timer or the RTI make sure the timer/RTI is setup to keep ticking in
Then execute these two commands in this order (without any commands in
asm CLI; // enable interrupts
asm WAI; // enter wait mode
HC(S)12 will guarantee that the command after the CLI gets executed
before any interrupts happen, preventing the system from going into
wait if an interrupt comes right as you execte the CLI.
Entering stop mode is done in a near identical fashion. Instead of
asm WAI, use asm STOP. Just remember that all the conditions that
wake the CPU from wait will not wake it from stop (such as SCI).
Hope this helps,