Page 358 - Programming Microcontrollers in C
P. 358

Digital Signal Processor Operations   343

                   #include “hc16.h”
                   #include “sim.h”
                   #include “qsm.h”

                   int putchar(char new_character);
                   void dprint (int c);
                   int handle_data(int new_data);

                   int data[64] @0x2000;
                   int coef[32] @0x2100;


                   void main(void)
                   {
                       int circular_conv(char, int*, char, int*);
                       int point[128],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 */
                   SCCR0.SCBR=55; /* set baud rate to 9600 */
                   SCCR2.TE=1; /* enable the transmit of the SCI */

                   for(i=0;i<64;i++)
                       data[i]=0x00;
                   for(i=0;i<32;i++)
                       coef[i]=0x100;
                   for(i=0;i<64;i++)
                   {
                   /* get new data—use 0x100 for this test */
                       ip=data+handle_data(0x100);
                       point[i]=circular_conv(64,ip,32,coef);
                   }
                   for(i=0;i<8;i++)
                   {
                          for(j=0;j<8;j++)
                          {
                              dprint(point[j+8*i]);
                              putchar(‘ ‘);
                          }
   353   354   355   356   357   358   359   360   361   362   363