Stamp
buffer. We start by moving the location of the first byte of
the buffer into the FSR, then adding the head pointer
(rxHead) to that. The MOV IND instruction takes the value
of rxByte and puts it into the location being pointed to
by the FSR. Then, we update the position of the head
pointer and make sure that it stays within a 0 to 15 range
by clearing bit 4. At the end of our serial section, we can
terminate the assembly code block of our ISR with the
ENDASM instruction.
Did you just take a big breath? I did! There
will come a point when this all seems trivial, but — until
you get to that point — you might want to review it a
few times. It wouldn’t hurt to map the position of the
counters and bits on paper so that you make sure you
understand it. By understanding how this works, you’ll
be able to modify it to suit your needs for a different
application.
Taking the Mystery Out
of Multiplexing
Remember that our project has another important
task: we have to multiplex the LED display, which
means selecting the active column (cathode) and then
activating the appropriate segments (anodes) to create
the desired pattern. We will handle this “in the background” via the ISR. This is actually much easier than
the serial code though and can be done with SX/B
instructions.
Multiplex:
INC digPntr
IF digPntr <= 7 THEN Next_Digit
digPntr = 0
Next_Digit:
Cathodes = NoDig
IF digPntr > limit THEN ISR_Exit
Anodes = anoBuf(digPntr)
IF digBlank = 1 THEN ISR_Exit
READ DigCtrl + digPntr, Cathodes
ISR_Exit:
RETURNINT 104
The first step is to increment the variable called
digPntr that points at the current active column. The next
line will compare the value of digPntr to 7 (last legal
column value) and, if digPntr is less than or equal to 7,
then we will move on to Next_Digit. Once digPntr hits 8,
Figure 2. SS8 schematic.
F
o
r
E
l
e
c
t
r
o
n
i
c
s
NUTS & VOLTS
E
v
e
r
y
t
h
i
n
g
80
JANUARY 2005