Page 355 - Programming Microcontrollers in C
P. 355

340    Chapter 6  Large Microcontrollers

                       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]=i*0x100;
                       for(i=0;i<32;i++)
                          coef[i]=(31-i)*0x100;

                       for(i=0;i<64;i++)
                       {
                          ip=data+i;
                          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(‘ ‘);
                          }
                              putchar(0xd);
                              putchar(0xa);
                       }
                   }


                   int putchar(char new_character)
                   {
                       while(SCSR.TDRE==0); /* wait until transmit buffer empty */
                       SCDR=new_character;/* send out byte and reset TDRE */
                   }
                   void dprint (int c)
                   {
                       if(c<0)
                       {
                          putchar(‘-’);
                          c=-c;
                       }
                       if ( c/10)
                       dprint(c/10);
                          putchar(c%10+’0');
                   }
                              Listing 6-11: A Test Program for Circular Convolution
   350   351   352   353   354   355   356   357   358   359   360