Page 350 - Programming Microcontrollers in C
P. 350
Digital Signal Processor Operations 335
n = log 2 (array length)
or
array length = 2 n
3. The value in xo must be equal to the step between adjacent
data samples in the array.
This scheme can be used to move, in a modular manner, around
multiple-dimensional arrays as well as one-dimensional arrays. Let
us now modify the earlier code to show how a circular buffer can be
used to advantage.
The above compilations use the default memory model for the
Cosmic C compiler for the MC68HC16. This computer has a memory
addressing space of 20 bits. In the design of the part, the basic address
registers were all made 16 bits wide, and the additional bits required to
address the total space were placed in extension registers. Therefore,
for each of the addressing registers, the stack pointer, the program
counter, and the index registers X, Y and Z, there is a 4-bit extension
register. These registers are called SK, PK, XK, YK, and ZK respec
tively. As mentioned earlier, several of these extension registers are
initialized upon reset, and the remainder must be initialized prior to
the execution of the main program. Usually, when a calculation alters
a value in an extension register, this change takes place seamlessly. It
is typically not necessary to worry about the contents of the extension
registers. Recall in the code for the initialization routine listed above,
crts.s, that the values for XK and ZK were set to 0 and the value
placed in YK was 0xf. The reason for this choice is that the compiler
automatically uses the Y register as an offset when calculating the ad
dresses listed in the various header files. Since all of these registers are
in the highest memory page, the YK value of 0xf is appropriate.
The default memory model is called the compact model, and the
code is compiled in the compact model so that all code, data, and stack
memory space is contained within one 65 kilobyte (K) memory bank.
Therefore, the initialized values of the extension registers need never
change. On the other hand, it is sometimes necessary to change the
values in these registers, and it is desirable to have the compiler take
care of this bookkeeping when needed. All of the additional memory
models will provide this tracking of the extension registers. These
models are: small, one 65 K bank for code and one 65 K bank for data