diff options
Diffstat (limited to 'lab5/RTDSP/intio.c')
-rw-r--r-- | lab5/RTDSP/intio.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/lab5/RTDSP/intio.c b/lab5/RTDSP/intio.c index 219ca56..8317826 100644 --- a/lab5/RTDSP/intio.c +++ b/lab5/RTDSP/intio.c @@ -1,11 +1,16 @@ /************************************************************************************* DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING IMPERIAL COLLEGE LONDON + EE 3.19: Real Time Digital Signal Processing Dr Paul Mitcheson and Daniel Harvey + LAB 3: Interrupt I/O + ********* I N T I O. C ********** + Demonstrates inputing and outputing data from the DSK's audio port using interrupts. + ************************************************************************************* Updated for use on 6713 DSK by Danny Harvey: May-Aug 2006 Updated for CCS V4 Sept 10 @@ -37,10 +42,13 @@ // PI defined here for use in your code #define PI 3.141592653589793 -short x[] = {0, 0}; -double y[] = {0.0, 0.0}; -double a[] = {1, -1.875/2.125}; -double b[] = {0.125/2.125, 0.125/2.125}; +#include "Matlab/filter_coeff_ell_a.txt" +#include "Matlab/filter_coeff_ell_b.txt" + +int N = sizeof(a)/sizeof(a[0]); +short* x; +double* y; + /******************************* Global declarations ********************************/ @@ -74,14 +82,24 @@ void ISR_AIC(void); short circ_fir(void); /********************************** Main routine ************************************/ void main(){ + int i; + x = (short*)calloc(N, sizeof(short)); + y = (double*)calloc(N, sizeof(double)); // initialize board and the audio port init_hardware(); /* initialize hardware interrupts */ init_HWI(); + + /* Initialises array to 0 */ + for (i = 0; i < N; ++i) { + y[i] = 0.0; + x[i] = 0; + } /* loop indefinitely, waiting for interrupts */ while(1) {}; + } /********************************** init_hardware() **********************************/ @@ -121,10 +139,22 @@ void init_HWI() /******************** INTERRUPT SERVICE ROUTINE ***********************/ void ISR_AIC() { - x[1] = x[0]; + int i; + + //Shift the values + for (i = N-1; i > 0; --i) { + x[i] = x[i-1]; + y[i] = y[i-1]; + } + x[0] = mono_read_16Bit(); - y[1] = y[0]; - y[0] = b[0] * x[0] + b[1] * x[1] - a[1] * y[1]; + y[0] = 0.0; + + for (i = 0; i < N; ++i) { + y[0] += b[i] * x[i]; + if (i != 0) + y[0] -= a[i] * y[i]; + } mono_write_16Bit((short)y[0]); -} +}
\ No newline at end of file |