project 3. implementation of iir digital filters in real...

28
UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO FACULTAD DE INGENIERÍA División de Ingeniería Eléctrica Semestre 2014-2 Project 3. Implementation of IIR digital filters in real time Report Digital Signal Processing Team 12 Elaborated by: García Sánchez Carlos Ignacio Magaña Vázquez José Luis Group: 01 ____________________________________________________________

Upload: lamhanh

Post on 26-Aug-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

UNIVERSIDAD NACIONAL AUTÓNOMA DE MÉXICO

FACULTAD DE INGENIERÍA

División de Ingeniería Eléctrica

Semestre 2014-2

Project 3. Implementation of IIR digital

filters in real time

Report

Digital Signal Processing

Team 12

Elaborated by:

García Sánchez Carlos Ignacio

Magaña Vázquez José Luis

Group: 01

____________________________________________________________

Page 2: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Index

Pág.

Introduction 3

Objective 3

Development

1. Analisis 3

2. Calculus 5

3. Simulation 7

4. Pseudo code 13

Results 14

Bibliography 14

Annex 15

Page 3: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Introduction

Filtering is one of the most common DSP operations. Understanding a digital filter as any

realizdo processing in a digital input signal, which can be implemented in hardware or

software. The advantage of the digital filter are high noise immunity, high precision (limited

by rounding errors in arithmetic used), easy modification of the filter characteristics and

low cost.Then we have a clasification of filters: (Finite Impulse Response) FIR filter and

(Infinite Impulse response) IIR Filter.

All FIR filters are discrete time filters. If we excite an FIR filter with a unit sample followed

by an infinite number of zero valued samples, we will have excited the system with the

discrete-time versión of an impulse function. Exciting an Nth order FIR filter wih an impulse

will result in N+1 output terms before all remaining terms will have a value of exactly zero.

Thus the impulse response is finite.

Another type of filter, called an IIR filter, has an Infinite Impulse Response. It is a recursive

filter, ya que la salida depende no solo de la entrada actual sino además de valores pasados

de la salida y la entradas.IIR filters can be either continous-time or discrete time.

Filtering can be used for noise supression, signal enhancement, removal or attenuaion of a

specific frequency. While this is not a complete list of all of the posible applications of filters,

it serves to remind the importance of filtering.

Objective

Design and implement FIR and IIR digital filters in real time on the DSP C2000 LaunchPad,

using audible signals and tones acquired in 4 different channels and the option to mix these

signals individually. For in the future design and implement a good quality equalizer.

Analisis

It is desired to implement IIR digital filters, band pass, low pass, high pass and bandstop.But

given the simplicity and stability of the FIR filter, why would you ever want to consider using

an IIR filter?

1.- There is a large amount of analog filtes design knowledge available and these analog

filters are all IIR in nature.

2.- To meet certain filter design specifications, very high order FIR filters may be needed.

Yet we can usually implement a lower order IIR filter that can meet such filter specifications.

As in almost always the case in engineering design, systems that perform well un some áreas

routinely perform poorly in other áreas. With IIR filters, we particulary concerned about

two issues:

Page 4: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Stability: Since feedback is always involved in an IIR design, the system may become

unestable. For real-time (causal) systems, we can ensure stability by keeping the poles

inside the unit circle. (Magniude of the poles<1).

The transfer function normally takes the form,

𝐻(𝑧) =𝑌(𝑧)

𝑋(𝑧)=𝑏0 + 𝑏1𝑧

−1 + 𝑏2𝑧−2 + 𝑏3𝑧

−3 +⋯

1 + 𝑎1𝑧−1 + 𝑎2𝑧−2 + 𝑎3𝑧−3 +⋯

Phase response: A FIR filter exhibits a linear phase response while an IIR filter does not

exhibit true linear phase. Depending on the application, having linear phase may be crucial

to the proper operation of the DSP-based filtering operation. If so, FIR filter are

recommended.

IIR Filter Notation

The generalized difference equation associated with a causal IIR filter is

∑𝑎[𝑘]𝑦[𝑛 − 𝑘]

𝑀

𝑘=0

=∑𝑏[𝑘]𝑥[𝑛 − 𝑘]

𝑁

𝑘=0

Where

𝑦[𝑛] = −∑𝑎[𝑘]𝑦[𝑛 − 𝑘]

𝑀

𝑘=1

+∑𝑏[𝑘]𝑥[𝑛 − 𝑘]

𝑁

𝑘=0

Where each of the remaining a[k] and b[k] terms are scaled by a[0]

Block Diagrams

Routinely, we use block diagrams to help unsderstand implemetation issues and signal flow.

In this case we use the direct form II diagram block for a second order IIR filter to program

the DSP.

Page 5: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Figure 1 Block Diagram of a second order IIR filter Direct Form II

Calculus

To introduce ourselves to the design of IIR filters and the implementation on real-time, first

we will implement second order IIR filters.

So in this case, we are interested on calculate the values a1, a2, b0, b1, and b2. There are

several methods to obtain these values. We will use the Butterworth aproximation,

obtaining the values from Matlab and its fdatool.

In the next table it is shown the cuttoff frequency of each filter we want to implement

Type Cuttoff frequency [Hz] Sampling frequency [Hz]

Band pass 256-2000 20000

High pass 2000 20000

Low Pass 256 20000

Stopband 1950-2050 20000 Table 1 Cuttoff frequency for each filter

Type a1 a2

Band pass -

1.5209720197393400 0.5612656298915490

High pass -

1.1429805025399000 0.4128015980961880

Low Pass -1.8863748828833600 0.8924920400561320

Stopband -

1.5695089782978500 0.9390625058174920

Table 2 Constants ai of the transfer function

Page 6: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Type b0 b1 b2

Band pass 0.2193671850542250 0.0000000000000000 -

0.2193671850542250

High pass 0.6389455251590220 -1.2778910503180400 0.6389455251590220

Low Pass 0.0015292892931913 0.0030585785863826 0.0015292892931913

Stopband 0.9695312529087450 -1.5695089782978500 0.9695312529087450 Table 3 Constants bi of the transfer function

Page 7: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Simulation

Figure 2 Passband Matlab simulation

Figure 3 High pass Matlab simulation

Page 8: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Figure 4 Low pass Matlab simulation

Figure 5 High pass Matlab simulation

We will use the DSP LaunchPad C2000, with operations of 32bits, in this way the format Qi

will be 28. Then the next table shows the values an and the values bn in Q28.

Type -a1 -a2 b0 b1 b2

Band pass 1855E6C2 F7050E55 0382872B 0 FC7D78D6

High pass 1249A5ED F9652A27 0A391EF2 EB8DC21E 0A391EF2

Low Pass 1E2E976E F1B85A45 64394 C8727 64394

Stopband 191CB573 F0F99999 0F833334 E6E34A8E 0F833334 Table 4 Qi=28 constants

Page 9: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

To test the each IIR filter, we introduce a signal of 400 samples, with a sampling frequency

of 20000Hz produced in Matlab using a digital dual-tone signal oscilator which contain a

dual-tone signal of 200Hz+2000Hz.

Figure 6 Double tone Matlab simulation

Testing each IIR filter by changing the constants of the transfer function of second degree. Using the software (CCS) Code Composer Studio 5.4, the data is loaded from a file. "Dat" with 400 samples of dual tone signal. Then proceeded to run the code done in assembly language, the graph of the magnitude of the fast Fourier transform, CCS tool included in which we can observe the frequency spectrum and conclude whether the result is as expected was obtained.

Page 10: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Figure 7 Debug CCS, FFT Magnitude set

Spectrum of double-tone signal is used as input to test each of the filters.

Figure 8 Spectrum frequency of the dual tone

Page 11: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

STOPBAND 2000HZ

Figure 9 Stopband spectrum frequency result

PASSBAND 256-2000 HZ

Figure 10 Passband spectrum frequency result

As for the band pass filter attenuation at both frequencies would be expected, but it is

observed that the attenuation is different for each frequency.

HIGH PASS 2000 HZ

Page 12: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Figure 11 High pass spectrum frequency result

LOW PASS 256HZ

Figure 12 Low pass spectrum frequency result

As for the low pass filter, a minimum attenuation is observed when the frequency of

2000Hz should have been attenuated by approximately 20 dB. The result of this low pass

filter can be improved by using a higher Qi.

Implementation:

A sampling frequency of 20 kHz was employed. Triggering the analog-digital channels 0,

converters 1, 2 and 3 by the Timer0. Counting on a EOC interrupt digital analog converter #

Page 13: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

3 wherein the mixture of signals depending on the selection in the switches that are stored

in a variable called "channels" is done. Besides band suppression filter to the sum of the

selected signals are implemented and at the end of processing proceeds to display the result

by 8 GPIOs (0-7) to an analog to digital converter 8 bits.

By means of an external interrupt initiated by a push button on the GPIO12, one can select

the four possible channels. Again press the push button on the GPIO12, the channels used

in the variable "channels" are saved.

Pseudo Code:

Main program:

1 - . Initialization of the addresses of the records of interest ( Interruptions, GPIOs , Timer0

, ADCs )

2 - . Initialization constants band suppression filter a1, a2 , b0 , b1 and b2

3 - . Reserve space for variable channel selection.

4 - . Disable WatchDog

. 5 - General Interrupt Disable

6 - . Configuring ADC interrupt and external interrupt GPIO12

. 7 - Configuring GPIOs as inputs and outputs

. 8 - time setting shot through ADCs TIMER0

9 - . ADC Configuration

10 - . Activating the general interruption

11 - . Infinite cycle interruptions for waiting .

EOC interrupt ADC3

1 - . BIT0 variable channels = 1 ? If so sum in the ACC register .

2 - . BIT1 variable channels = 1 ? If so sum in the ACC register .

3 - . BIT2 variable channels = 1 ? If so sum in the ACC register .

4 - . BIT3 variable channels = 1 ? If so sum in the ACC register .

5 - . Conditioning Qi result of the sum of the samples in the ACC record for processing.

. 6 - Implementation of suppression filter at 2000Hz band .

Page 14: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

. 7 - Saving to the ACC record result is suitable for output through the GPIOs (0-7 ) for digital

analog conversion.

8 - . Reactivation of the interrupt.

9 - . Return to infinite loop in the main program.

External interrupt GPIO12

1.- Disables general interruption

. 2 - Delay

3 - . Wait renewed pressure on the GPIO12 button until button is pressed again goes to 4

. 4 - Read the bits set in the channel selection switches .

. 5 - Keep reading in the variable " channels "

6 - . Enabling GPIO external interrupt

. 7 - Activating the general interruption .

. 8 – Return to infinite loop in the main program.

Results:

We obtained a good response from the stopband, in the video we can see how the signals

are mixed and how the signal from the frequency generator set to 2000Hz it is suppressed.

https://www.youtube.com/watch?v=7zMAniFgrgE

Page 15: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

ANNEX

ANNEX 1

PROGRAM OF QI OBTENTION ON MATLAB

function [bin]= QI(num,qi) nume=ceil((2^qi).*num); for i=1:length(nume) if nume(i)<0 nume(i)=(2^32)+nume(i); end end %bin=nume; bin=dec2hex(nume); end ANNEX 2

SIMULATION ON MATLAB FOR IIR FILTER clc; clf; wc=210; f0=200; Af=5; f2=f0+Af; f1=f0-Af; Fs=20000; N=2; Fs5=Fs*5; x=5*sin(2*pi*100*(1:Fs)/Fs)+5*sin(2*pi*1000*(1:Fs)/Fs)+5*sin(2*pi*3000*(1

:Fs)/Fs);%+2*sin(2*pi*f04*(1:Fs)/Fs); xw=abs(fft(x));%calcula el espectro discreto de x con fft

wcd=[2*256/Fs];% Frecuencia de corte normalizada de 0 a 1 [B A]=butter(2,wcd,'low'); y=filter(B,A,x);%Resuelve ec. en dif. yw=abs(fft(y));% Calcula el espectro discreto de y con fft

[H w]=freqz(B,A,Fs/2);%Obtiene la respuesta en frecuencia del filtro

subplot(511),plot(x); title('señal de entrada'); subplot(512),plot(xw(1:Fs/5)); title('espectro de x'); subplot(513),plot(y); title('señal de y'); subplot(514),plot(yw(1:Fs/5)); title('espectro de y'); subplot(515),plot(abs(H(1:Fs/5))); title('respuesta de IIR');

Page 16: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

ANNEX 3

PROGRAM TO OBTEIN THE SAMPLES TO TEST IIR FILTER ON MATLAB

f1=2000; f2=200; fs=20000; N=400; wd1=2*pi*f1/fs; wd2=2*pi*f2/fs; A1=sin(wd1)+sin(wd2) B1=2*(cos(wd1)*sin(wd2)+cos(wd2)*sin(wd1)); C1=2*(cos(wd1)+cos(wd2)); D1=2+4*(cos(wd1)*cos(wd2)); y10=0; y11=A1; y12=(-B1+C1*y11); y13=A1+C1*y12-D1*y11; v1=[1:1:N]; for i=1:N v1(i)=0; end v1(1)=y10; v1(2)=y11; v1(3)=y12; v1(4)=y13; for i=5:N v1(i)=(C1*v1(i-1))-(D1*v1(i-2))+(C1*v1(i-3))-v1(i-4); end plot(v1) grid on max(v1) min(v1) v1q=QI(v1,28); escribe(v1q)

Page 17: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

ANNEX 4

PROGRAM ON ASSEMBLY LANGUAJE TO TEST EACH IIR FILTER

.global _c_int00 .data DIR_WDCR .set 07029h DIR_SP .set 00600h N .set 400 bas .long 0 b0 .long 0F833334h b1 .long 0E6E34A8Eh b2 .long 0F833334h a1 .long 0191CB573h a2 .long 0F0F99999h ln .long 0 ln1 .long 0 ln2 .long 0 x .space 32*N y .space 32*N .text _c_int00 ;DESACTIVAR WATCHDOG EALLOW MOVL XAR0,#DIR_WDCR MOV *XAR0,#0068h EDIS SETC SXM SPM #0 ZAPA MOVW DP,#bas MOVL XAR1,#x MOVL XAR2,#y MOV AR5,#N-1 CIC ZAPA MOVL ACC,*XAR1++ MOVL XAR3,#a1 MOVL XAR7,#ln1 RPT #1 || QMACL P,*XAR3++,*XAR7++ ADDL ACC,P ;LSL ACC,#4 MOVL @ln,ACC ZAPA

Page 18: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

MOVL XAR3,#b0 MOVL XAR7,#ln RPT #2 || QMACL P,*XAR3++,*XAR7++ ADDL ACC,P ;LSL ACC,#4 MOVL *XAR2++,ACC MOVL ACC,@ln1 MOVL @ln2,ACC MOVL ACC,@ln MOVL @ln1,ACC BANZ CIC,AR5-- FIN NOP LB FIN .end ANNEX 5

PROGRAM OF REAL-TIME MIX CHANNEL AND STOPBAND IMPLEMENTATION

.global _c_int00 ;DIRECCIONES DE REGISTROS DIR_WDCR .set 07029h DIR_SP .set 00600h DIR_PIECTRL .set 0x00CE0 DIR_PIEACK .set 0x00CE1 DIR_PIEIER1 .set 0x00CE2 DIR_PIEIFR1 .set 0x00CE3 DIR_PIEIER10 .set 0x0CF4 DIR_PIEIFR10 .set 0x0CF5 DIR_GPIOXINT1SEL .set 0x6FE0 DIR_XINT1CR .set 0x7070 DIR_XINT1CTR .set 0x7078 DIR_GPACTRL .set 0x6F80 DIR_GPAQSEL1 .set 0x6F82 DIR_INT14 .set 0D46h DIR_GPAMUX1 .set 06F86h DIR_GPAMUX2 .set 06F88h DIR_GPADIR .set 06F8Ah DIR_GPAPUD .set 06F8Ch

Page 19: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

DIR_GPBMUX1 .set 06F96h DIR_GPBDIR .set 06F9Ah DIR_GPADAT .set 06FC0h DIR_GPASET .set 06FC2h DIR_GPACLEAR .set 06FC4h DIR_GPATOGGLE .set 06FC6h DIR_GPBDAT .set 06FC8h DIR_GPBPUD .set 06F9Ch DIR_GPBSET .set 06FCAh DIR_GPBCLEAR .set 06FCCh DIR_GPBTOGGLE .set 06FCEh DIR_PCLKCR3 .set 07020h DIR_ITIM0 .set 0D4Ch DIR_TIMPRDL .set 0C02h DIR_TIMPRDH .set 0C03h DIR_TIM0TCR .set 0C04h C_WDCR .set 0068h PER_H .set 0000h PER_L .set 01F4h DIR_PCLKCR0 .set 0701Ch DIR_ADCCTL1 .set 07100h DIR_ADCSOCFOR .set 0711Ah DIR_ADCSOC0CTL .set 07120h DIR_ADCSOC1CTL .set 07121h DIR_ADCSOC2CTL .set 07122h DIR_ADCSOC3CTL .set 07123h DIR_ADCMODE .set 07112h DIR_INTSEL1N2 .set 07108h DIR_SOCPRICTL .set 07110h DIR_ADCRESULT0 .set 00B00h DIR_ADCRESULT1 .set 00B01h DIR_ADCRESULT2 .set 00B02h DIR_ADCRESULT3 .set 00B03h DIR_V_ADCINT10 .set 00DD0h .data N .set 800 bas .long 0 salida .long 0 canales .word 0 filtro .word 0

Page 20: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

b0 .long 0F833334h b1 .long 0E6E34A8Eh b2 .long 0F833334h a1 .long 0191CB573h a2 .long 0F0F99999h ln .long 0 ln1 .long 0 ln2 .long 0 ;x .space 32*N y .space 32*N .text _c_int00 SETC INTM MOV SP,#DIR_SP AND IFR,#0FFFFh EALLOW MOVL XAR1,#DIR_WDCR MOV *AR1,#C_WDCR ;PIE MOVL XAR0,#DIR_PIECTRL MOV AL,*AR0 OR AL,#0x0001 MOV *AR0,AL ;INTERRUPCIONES INT10.1 MOVL XAR0,#DIR_PIEIER10 MOV AL,*AR0 OR AL,#0x0001 MOV *XAR0,AL ;AHORA LA HABILITACION DEL PIE INT1.4 MOVL XAR0,#DIR_PIEIER1 MOV AL,*XAR0 OR AL,#0x0008 MOV *XAR0,AL ;RUTINA ADC MOVL XAR2,#DIR_V_ADCINT10 MOV ACC,#MI_GPIO_INT ;MOV AH,#03Fh MOVL *XAR2,ACC ;RUTINA GPIO MOVL XAR0,#DIR_INT14

Page 21: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

MOV ACC,#RUTINA ;MOV AH,#03Fh MOVL *XAR0,ACC ;CONFIGURA EL GPAMUX1 PARA PONER EL PINES COMO GPIO MOVL XAR0,#DIR_GPAMUX1 MOV ACC,#0x0000 MOVL *XAR0,ACC MOVL XAR0,#DIR_GPAMUX2 MOV ACC,#0x0000 MOVL *XAR0,ACC MOVL XAR0,#DIR_GPBMUX1 MOV ACC,#0x0000 MOVL *XAR0,ACC MOVL XAR0,#DIR_GPADIR MOV AL,#0x00FF MOV *XAR0,AL MOVL XAR0,#DIR_GPBDIR MOV AL,#0x0004 MOV *XAR0,AL ;CONFIGURACION DEL GPIO12 COMO BOTON E INTERRUPCION ;GPAPUD DESACTIVA/ACTIVA LA RESISTENCIA DE PULL UP MOVL XAR0,#DIR_GPAPUD MOV AL,#0x1FFF MOV AH,#0x000F MOVL *XAR0,ACC MOVL XAR0,#DIR_GPBPUD MOV AL,#0x0004 MOV *XAR0,AL ZAPA ;TIEMPO DE MUESTREO MOVL XAR0,#DIR_GPACTRL MOV ACC,#0xFF00 MOVL *XAR0,ACC ZAPA ;NUMERO DE MUESTRAS PARA CAMBIAR ESTADO MOVL XAR0,#DIR_GPAQSEL1 MOV AH,#0x0200 MOVL *XAR0,ACC ;GPIOXINT1SEL, PARA CONFIGURAR EL GPIO12 COMO INTERRUPCION DE XINT1

Page 22: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

MOVL XAR0,#DIR_GPIOXINT1SEL MOV ACC,#12 MOVL *XAR0,ACC ;XINT1CR, HABILITAR INTERRUPCION XINT1 Y FLANCO DE INTERRUPCION MOVL XAR0,#DIR_XINT1CR MOV AL,*XAR0 OR AL,#5 MOV *XAR0,AL ;CARGA PERIODO DE TIMER0 MOVL XAR1,#DIR_TIMPRDH MOV AL,#PER_H MOV *XAR1,AL MOVL XAR1,#DIR_TIMPRDL MOV AL,#PER_L MOV *XAR1,AL ;ACTIVAR IE EN TIMER0CR 0x0C04 MOVL XAR0,#DIR_TIM0TCR MOV AL,*XAR0 OR AL,#0x4000 MOV *XAR0,AL ;ADC MOVL XAR1,#DIR_PCLKCR0 MOV AL,*XAR1 OR AL,#0008h MOV *XAR1,AL NOP NOP NOP MOVL XAR1,#DIR_ADCCTL1 MOV AL,*XAR1 ;OR AL,#0C0E0h OR AL,#40E4h ;#40E0h MOV *XAR1,AL MOVL XAR0,#DIR_ADCMODE MOV AL,#00 MOV *XAR0,AL MOVL XAR0,#DIR_SOCPRICTL MOV AL,#0004h MOV *XAR0,AL

Page 23: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

MOVL XAR1,#DIR_ADCSOC0CTL MOV AL,#0806h MOV *XAR1,AL MOVL XAR1,#DIR_ADCSOC1CTL MOV AL,#0846h MOV *XAR1,AL MOVL XAR1,#DIR_ADCSOC2CTL MOV AL,#0886h MOV *XAR1,AL MOVL XAR1,#DIR_ADCSOC3CTL MOV AL,#08C6h MOV *XAR1,AL MOVL XAR1,#DIR_INTSEL1N2 MOV AL,#0063h MOV *XAR1,AL EDIS OR IER,#0x0200 OR IER,#0x0001 CLRC INTM MOVW DP,#bas SETC SXM SPM #0 MOVL XAR2,#y ;MOV AR5,#N-1 ZAPA NOP NOP FIN NOP B FIN,UNC MI_GPIO_INT INC @filtro CMP @filtro,#800 SB VENGA,NEQ MOV @filtro,#0 MOVL XAR2,#y VENGA ZAPA MOVL XAR0,#DIR_GPBTOGGLE MOV AL,*XAR0

Page 24: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

OR AL,#0004 MOV *XAR0,AL ZAPA TBIT @canales,#0 SB N1,NTC MOVL XAR0,#DIR_ADCRESULT0 ADD ACC,*XAR0 N1 TBIT @canales,#1 SB N2,NTC MOVL XAR0,#DIR_ADCRESULT1 ADD ACC,*XAR0 N2 TBIT @canales,#2 SB N3,NTC MOVL XAR0,#DIR_ADCRESULT2 ADD ACC,*XAR0 N3 TBIT @canales,#3 SB N4,NTC MOVL XAR0,#DIR_ADCRESULT3 ADD ACC,*XAR0 N4 ;MOVL XAR0,#DIR_ADCRESULT0 ;MOV AL,*XAR0 MOVL *XAR2++,ACC MOV AH,@AL MOV AL,#0 MOVL XAR3,#a1 MOVL XAR7,#ln1 RPT #1 || QMACL P,*XAR3++,*XAR7++ ADDL ACC,P ;LSL ACC,#4 MOVL @ln,ACC ZAPA MOVL XAR3,#b0 MOVL XAR7,#ln RPT #2 || QMACL P,*XAR3++,*XAR7++ ADDL ACC,P ;LSL ACC,#4 ;MOVL *XAR2++,ACC MOVL @salida,ACC

Page 25: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

LSL ACC,#3 ;SFR ACC,#8 AND AH,#00FFh MOVL XAR0,#DIR_GPADAT MOV *XAR0,AH MOVL ACC,@ln1 MOVL @ln2,ACC MOVL ACC,@ln MOVL @ln1,ACC EALLOW MOVL XAR0,#DIR_PIEACK MOV *XAR0,#0x0200 EDIS IRET RUTINA NOP SETC INTM NOP NOP MOVL XAR0,#DIR_GPADAT MOV AR4,#0xFFFE NADA NOP TBIT *XAR0,#12 SB NADA,NTC LC DELAY NADA2 NOP TBIT *XAR0,#12 SB NADA2,TC MOVL ACC,*XAR0 MOV @canales,AH MOVL XAR0,#DIR_GPBDAT MOV AL,*XAR0 AND AL,#0x0FFFB MOV *XAR0,AL EALLOW MOVL XAR0,#DIR_PIEIFR1 MOV AL,*XAR0 XOR AL,#0x0008 MOV *XAR0,AL MOVL XAR0,#DIR_PIEACK ;SE ACTIVA DE NUEVO LA INTERRUPCION MOV AL,#0x0001

Page 26: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

MOV *XAR0,AL EDIS ;AND IFR,#0FFFFh CLRC INTM IRET DELAY MOV AR3,#0x001F LOOP RPT AR4 || NOP BANZ LOOP,AR3-- LRET .end

IMAGES

Image 1 Development board for LaunchPad C2000

Page 27: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Image 2 Development board with LaunchPad C2000

Page 28: Project 3. Implementation of IIR digital filters in real …e2e.ti.com/cfs-file/...00-18-56-73-Attached+Files/...of-iir-filter.pdf · Implementation of IIR digital filters in

Image 3 Test of the development board for LaunchPadC2000