Page 341 - Programming Microcontrollers in C
P. 341
326 Chapter 6 Large Microcontrollers
Digital Signal Processor Operations
Most microcontrollers, regardless of their basic speed, are not
really able to process signals in real time. The basic speed of the
processors is fast enough to accomplish most signal processing; how
ever, the set of things needed to do digital signal processing is not
usually available in the regular microcontroller. The basic digital sig
nal processor (DSP) function that is required is summarized by three
actions: 1) the processor must multiply two values, 2) the processor
must add the product into a value, and 3) it must prepare for the next
multiply. This set of operations must execute quickly enough that the
computer can keep ahead of the real-time input of data being pro
cessed. Almost all signal processing operations are based on the
multiply-accumulate sequence. Filtering, correlation operations, sca
lar products of vectors, Fourier and other transformations, and
convolutions are but a few of the operations that are built around the
DSP multiply and accumulate sequence above. The MC68HC16 fam
ily has an extension to its core that can execute basic DSP operations
fast enough to support real-time filtering, correlation, and so forth.
Unfortunately, C compilers do not know of these added func
tions, so the C programmer would seem to be unable to include DSP
operations in programs. We will see here that, while it is rather in
convenient, it is possible to write assembly functions that will permit
the programmer access to the complete DSP capabilities found in
this family of devices.
One of the good features of C is that it is not necessary for the
programmer to have detailed knowledge of the nature of the basic
computer being programmed. So far, we have had little to say about
accumulators or index registers or the like. No more! We must now
get inside of the computer to create functions that will accomplish
our DSP needs. When these functions are complete, we should be
able to treat the DSP operations in much the same manner that we
would any other function call. The DSP contains four registers and
controls three bits in the condition code register (CCR). The first two
registers are called the MAC multiplier input registers H and I, re
spectively. These registers must be loaded with the multiplier and
the multiplicand to be executed. Data stored in these registers are
signed fractional binary numbers with the radix point between bits
15 and 14. The product will be accumulated into the MAC accumu