// C31FILT.C - C31 FILTER PROGRAM // // this program allows you to download data from the PC and process // it on the DSK board. It uses a handshaking approach. It is intended // to be run using the freader program. // // function: filter // // arguments: // short int* in: a pointer to the input sample // short int* out: a pointer to the output sample // int process: a flag that controls initialization // // return: none // // this function processes one sample at a time. the user can // initialize any internal variables by setting process=0, // and can process a sample by setting process=1. // void filter(short int *in, short int *out, int process) { // declare local variables // float acc = 0; // initialization step // if (process == 0) { acc = 0; } // process step // else if (process == 1) { acc = *in; *out = acc; } } // main program // // this program serves as a driver for the filter function // users need not modify this program // // main() { // declaration of variables // int i = 0; int init = 0; float din = 0.0, dout = 0.0; int ready = 1, start = 0, done = 0; short int *DSP_READY, *START, *DONE, *OUT, *IN; // reserve the memory address locations on the dsp // for status flags and registers // DSP_READY = (short int *)0x809800; // dsp ready status START = (short int *)0x809801; // dsp start flag DONE = (short int *)0x809802; // dsp done status IN = (short int *)0x809803; // data input address OUT = (short int *)0x809804; // data output address // initialize filter variables // init = 0; filter((short int *)NULL, (short int *)NULL, init); // initialize dsp status flags and registers // *START = start; *DONE = done; *OUT = dout; *IN = din; *DSP_READY = ready; for (;;) { // while ready == 1 and start == 0 // note that the PC sets start to 1 after reading // a true value for ready // while (ready == 1) { asm("IDLE"); start = *START; if (start == 1) { ready = 0; *DSP_READY = ready; } } // the PC has set start to 1, which means DSK is ready // to receive the data // // process the data when it is received // asm("IDLE"); init = 1; filter((short int *)IN, (short int *)OUT, init); // pull start low // start = 0; *START = start; // pull done high, signalling the PC to read output // done = 1; *DONE = done; // wait for the PC to pull down low // while (done == 1) { done = *DONE; } // initialize for next iteration // ready = 1; *DSP_READY = ready; } }