EmbeddedRelated.com
Forums

ATD and WAIT

Started by amirkln December 19, 2005
Hello all,
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.



Amir,

Regarding your second question:
To start the WAIT mode you need the CPU needs to execute the WAI assembly
instruction.
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,
Doron
Nohau
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html

At 21:55 19/12/2005 +0000, you wrote:
>Hello all,
>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.




Hi Amir,

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
scenario:

Firstly disable all interrupts:
asm SEI;

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
wait mode.

Then execute these two commands in this order (without any commands in
between):
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,
Adi