From 15f14bfcf580dcf123178e254246e7993d077e63 Mon Sep 17 00:00:00 2001 From: ymherklotz Date: Tue, 27 Feb 2018 10:27:11 +0000 Subject: Fixed proj lab5ex1 --- lab5/RTDSP/intio.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'lab5/RTDSP/intio.c') diff --git a/lab5/RTDSP/intio.c b/lab5/RTDSP/intio.c index 124fc03..219ca56 100644 --- a/lab5/RTDSP/intio.c +++ b/lab5/RTDSP/intio.c @@ -1,16 +1,11 @@ /************************************************************************************* 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 @@ -36,16 +31,16 @@ // Some functions to help with writing/reading the audio ports when using interrupts. #include -#include "Matlab/filter_coeff.txt" // Some functions to help with configuring hardware #include "helper_functions_polling.h" // PI defined here for use in your code #define PI 3.141592653589793 -#define N 249 -double buffer[N]= {0}; -unsigned ptr = N-1; +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}; /******************************* Global declarations ********************************/ @@ -126,23 +121,10 @@ void init_HWI() /******************** INTERRUPT SERVICE ROUTINE ***********************/ void ISR_AIC() { - buffer[ptr] = (double) mono_read_16Bit(); - mono_write_16Bit((short)circ_fir()); - if (ptr == 0) - ptr = N; - ptr--; -} - -// Perform linear convolution -short circ_fir() -{ - double y = 0; - int i = 0; - for(; i+ptr < N; i++) { - y += buffer[i+ptr] * b[N-i-1]; - } - for(; i < N; i++) { - y += buffer[i+ptr-N] * b[N-i-1]; - } - return y; + x[1] = x[0]; + x[0] = mono_read_16Bit(); + y[1] = y[0]; + y[0] = b[0] * x[0] + b[1] * x[1] - a[1] * y[1]; + + mono_write_16Bit((short)y[0]); } -- cgit