Page 354 - Programming Microcontrollers in C
P. 354
Digital Signal Processor Operations 339
fore, there will be a circular buffer calculation on X, but there will be
no circular calculation on the Y register.
After the MASKs are set up, the two 20-bit pointer registers, X
and Y, are assigned the values passed as parameters, and then the
product data are put into place. The rmac instruction is then ex
ecuted the number of times indicated by the contents of the E register.
The register contents are then restored and the result of the single-
point convolution is moved into the D register before control is
returned to the calling program.
A simple program was written to test the operation of this func
tion. This function does not attempt to make a digital filter, but it rather
sets up to show how the circular convolution works. In this case, it was
intended that the program run on an EVB16 board that has a normal
serial interface to an RS232 port. Therefore, the data being tested can
be sent out of the serial port to a terminal. The purpose of the program
is really quite simple. It is to execute a convolution between a short set
of coefficients and a long set of data. The coefficient set is 32 integers
long, and the data set is 64 integers long. The coefficient data is a
descending array of numbers that are in the upper byte of the number.
These numbers start at 31 and reduce successively to zero. The data
that will be used here are merely the numbers 0 through 63 in the
upper byte of the number. The system is set up, the system frequency
is set to 16.78 MHz, and the watchdog is disabled. The serial port is set
to 9600 baud and the SCI transmitter is enabled.
#include “hc16.h”
#include “sim.h”
#include “qsm.h”
int putchar(char new_character);
void dprint (int c);
void main(void)
{
int circular_conv(char, int*, char, int*);
int data[64], coef[32],point[64],i,j,*ip;
/* initialize the SIM */
SYNCR.X=1; /* set the system freq to 16.78 MHz */
SYPCR.SWE=0; /* disable the watchdog */
/* initialize the SCI */