CSE477 Notes for "EX10.asm"
Overview
These notes will help get an understanding of sections 10-3, 10-5,
and 10-6, which have to be shown to a TA. Simply work through all of the
examples in the assembly code program "EX10.ASM".
You'll need to review the code carefully to understand how to use it in
the lab. An explanation of this code (including the starting addresses
for each of the main routines) is sprinkled throughout Chapter 10 of the
MC68HC11 Reference Manual (the thicker pink manual).
Notes
-
Items to note in each main routine:
-
The initial equates set up aliases to be used in all the key registers.
-
10-1 is a straight-forward input capture routine where the captured
data is manipulated for suitable output. The captured period is converted
to frequency and then the frequency from base 16 to base 10. It is then
output with extra text by means of the built-in print functions (also useful
for print routines for debugging).
-
10-2 is similar to 10-1 only that it uses interrupts rather than
polling when the input capture takes place. Data manipulation is performed
again but by use of general subroutines that are at the end of the .ASM
file.
-
10-3 demonstrates measuring long periods using interrupts and the
Timer Over Flow interrupt handler. A point that may be difficult to absorb
at first is the data manipulation to divide the data that was spread across
three bytes in memory (a big number due to the long capture time). To divide
by 2, normally only a logical shift left is required. However, since the
data is spread over three bytes, Rotate Right commands are used so the
LSB of one byte can be passed to the Carry bit, where it is subsequently
passed into the next byte on an ROR instruction. You may want to review
these instructions.
-
10-4 is an example of a simple Output Compare function. It drives
the LSB of port B with a 40ms duty cycle. 10ms of the cycle are high.
-
10-5 requires the user to enter a half-cycle delay at $D000 and
$D001 using memory modify (MM) before the program is executed. The output
compare function is handled with interrupts.
-
10-6 produces two pulse width modulated signals. It also requires
the user to set three values before executing the program. It's important
to note that OC1 is used to schedule and time signals out of OC2 and OC3.
However, OC2 and OC3 control their own output levels.
-
10-7 uses OC2 alone to produce one pulse width modulated (PWM) signal.
Again, two values have to be manually entered before the execution of the
program. The output compare is interrupt driven.
-
The example listings are followed by some utility routines that are called
at various times for data manipulation. All of the main routines have small
header sections describing their function. H6TOD8 is a bit tricky in the
third block of the section denoted by label "HLPIN" where $2F is added
to a digit to convert it to ASCII -- since the value was already one greater
than needed, $2F was added instead of the $30 we might have expected. The
FCC and FCB statements at the end are used to hold constants that are referenced
by the routines.
-
Most of the addressing dealing with the IC/OC registers is done with a
base/offset scheme. For example,
REGBAS EQU $1000 Starting address for register block
TFLG1 EQU $23 OC1F,OC2F,OC3F,OC4F;OC5F,IC1F,IC2F,IC3F
.
.
.
LDX REGBAS
STAA TFLG1,X Clear any old OC1 flag
assigns values to REGBAS and TFLG1. Register X is then loaded with the
"base" value of $1000, which is used as the base value to be added to $23
to point to a location $23 bytes after $1000. This is accomplished using
the indexed addressing mode of the STAA instruction.
While the code is documented to some extent, a reasonable amount of time
is needed in understanding how it is organized and the schemes (which are
quite typical) used in the binary to decimal conversion routines (used
in EX 10-1b and the 24-bit used in EX 10-2).
RMB stands for "Reserve Memory Block" and is usually preceded by
an ORG statement as a starting base. Memory blocks are reserved
in byte increments. ex:
ORG $C400
RMB 2 DATA
would reserve locations $C400 and $C401 for software use. No instructions
would be allowed to be placed in this spot during program assembly.
FCC and FCB stand for Form Constant Character and Form Constant
Byte. These are used as data statements to hold strings or other data in
an assembly program. An example is the output string "Program mode:".
Comments to: cse477-webmas
ter@cs.washington.edu (Last Update:
)