Hardware Reference
In-Depth Information
Figure 9.7 Touch-operated switch
Figure 9.8 Latching action switch
Pressing the switch causes the bistable to change state. The bistable then
remains in that state until the switch is depressed a second time. If desired, the
complementary outputs provided by the bistable may be used to good effect by
allowing the /Q output to drive an LED. This will become illuminated whenever
the Q output is high.
Software debouncing
Software debouncing involves the execution of a delay routine whenever the
state of a switch is read. The state of the switch at the start of the delay routine
is compared with that at the end. If the same value is returned in both cases, the
last value returned is assumed to represent the state of the switch. If the value
has changed, the switch is read again. The period of the delay routine is chosen
so that it is just greater than the maximum period of contact bounce expected
(typically 4 to 10 ms).
A typical software debounce routine is given below:
readsw: CALL switch
; Read the switch and
MOV
BL, AL
; store the value.
CALL swdelay
; Wait and then
CALL switch
; read it again.
Search WWH ::




Custom Search