STOP mode on the 68HC11


Many years ago, I built an acoustic sensor based on a 68HC11 cpu card from New Micros, Inc. This sensor was to be moored in the Arabian Sea for 6 months, taking data at 20 minute intervals. A separate battery pack of alkaline D-cells provided power. In order to conserve power as much as possible, I elected to use the STOP mode of this processor. By careful attention to turning things off and setting bit-lines appropriately, I managed to get the STOP mode power down to about 100 micro-amps. Too low, really, to measure with a DVM.

This is the code (go2sleep) that setup a low-power mode and then executed STOP mode. I used a RTC chip on the IRQ line to interrupt the processor and wake up the system. One could use the RTI interrupt as well but the timing accuracy might not be as good.


code-sub cli ( clear interrupt flag to enable interrupts
0e c, ( cli
39 c, ( rts
end-code

code-sub sei ( set interrupt flag to disable interrupts
0f c, ( sei
39 c, ( rts
end-code

code-sub stop ( enter CPU stop mode, clocks off
07 c, ( tpa
847f , ( and #$7f
06 c, ( tap
cf c, ( stop
39 c, ( rts
end-code

code-sub rtc-irq ( basic rtc interrupt service routine
f6 c, reg-d , ( ldab reg-d get current reg-d
c4 c, fb c, ( andb #fb and irq flag to zero
f7 c, reg-d , ( stab reg-d clear irq flag only
3b c, ( rti
end-code

variable vec-table -2 allot
7e c, fffe @ , ( b7bf sce ser sys
7e c, fffe @ , ( b7c2 spe ser
7e c, fffe @ , ( b7c5 pls acc ovfl
7e c, fffe @ , ( b7c8 pls acc edge
7e c, fffe @ , ( b7cb tmr ovfl
7e c, fffe @ , ( b7ce tmr out comp 5
7e c, fffe @ , ( b7d1 tmr out comp 4
7e c, fffe @ , ( b7d4 tmr out comp 3
7e c, fffe @ , ( b7d7 tmr out cmp 2
7e c, fffe @ , ( b7da tmr out cmp 1
7e c, fffe @ , ( b7dd tmr out cap 3
7e c, fffe @ , ( b7e0 tmr out cap 2
7e c, fffe @ , ( b7e3 trm in cap 1
7e c, fffe @ , ( b7e6 real time
7e c, ' rtc-irq @ , ( b7e9 irq
7e c, fffe @ , ( b7ec xirq
7e c, fffe @ , ( b7ef swi
7e c, fffe @ , ( b7f2 op-code trap
7e c, fffe @ , ( b7f5 cop failure
7e c, fffe @ , ( b7f8 clk mon
here is vec-table-end

: vec-init ( check and move vectors if necessary )
vec-table-end vec-table - 0 ( range)
do
b7bf i + c@ vec-table i + c@ = not
if vec-table i + c@ b7bf i + ." ." eec! then
loop
;
: enable
sei ( disable interrupts
vec-init ( setup interrupt jump vectors
;

( Enter STOP mode with all external circuits shut off
hex
: go2sleep
adc-on
fc spdr c! 0 spdr c!
0 spdr c! ( shut down ADC
adc-off
temp-off ( ensure 7109 is off
1 set-ch ( ensure channel adr's = 0
set-pwr0 ( ensure acoustics unit is off
cli ( enable interrupts
stop ( stop CPU clocks until RTC interrupt
sei ( disable interrupts
read-clock ( get the time
display-time cr ( output the time
;
decimal