// *********dftest.c *************** // FIR digital filer example // y(n) = (x(n) + x(n-K))/2 // ICC12 compiler generates efficient code for K = 3,7,15,31 etc // Last modified 12/15/02 by Jonathan W. Valvano // Copyright 2003 by Jonathan W. Valvano, valvano@uts.cc.utexas.edu // You may use, edit, run or distribute this file // as long as the above copyright notice remains #include "HC12.h" #include "SCI12.H" #define K 3 #define N (K+1) int Xdata[N]; // MACQ unsigned int n; // index into MACQ #define x(m) Xdata[(n+m)%N] //******** msecwait *************** // wait for a variable amount of time // uses output compare 5 void msecwait(unsigned int msec){ unsigned int i,j; for(i=0; i>1; return y; } void main(void){ int in,out; InitFilter(); // initialize Filter, COP, Port T SCI_Init(13); SCI_OutString("Adapt812 Digital Filer test 12/15/02 -JWV"); SCI_OutChar(CR); SCI_OutString("x(n) y(n)"); SCI_OutChar(CR); while(1){ for(in=10; in<=90; in=in+5) { // simulated triangle wave data PORTT ^= 0x40; // toggle LED, for debugging SCI_OutUDec(in); SCI_OutChar(SP); out = Filter(in); SCI_OutUDec(out); SCI_OutChar(CR); msecwait(2000); } for(in=85; in>10; in=in-5) { // simulated data PORTT ^= 0x40; // toggle LED SCI_OutUDec(in); out = Filter(in); SCI_OutChar(SP); SCI_OutUDec(out); SCI_OutChar(CR); msecwait(2000); } } } extern void _start(); #pragma abs_address:0xfffe void (*reset_vector[])() = { _start }; #pragma end_abs_address #include "SCI12.C"