Está en la página 1de 2

#define M 17

//Funcin de trasferencia h[n]


const float h[]=
{
0.0018052104538582, //h(0)
0.00905810215732946, //h(1)
0.00179096961917994, //h(2)
0.00393014193876244, //h(3)
0.0307760790492056, //h(4)
-0.0879236273273945, //h(5)
-0.218010454414228, //h(6)
0.078115497545518, //h(7)
0.384167993159943, //h(8)
0.0832388331308223, //h(9)
-0.248392736747743, //h(10)
-0.107904878578323, //h(11)
0.0411879382357919, //h(12)
0.00583790841302624, //h(13)
0.00299868100666665, //h(14)
0.0163162389068139, //h(15)
0.00250614601893693 //h(16)
};
//Declaracin de varales.
float x0, y0;
float x[M];
unsigned int YY;
unsigned short i;
//Declaracin de la funcin de interrupciones.
void interrupt ( void )
{
if( INTCON.F2 )
{
TMR0L=135;
PORTC.F7=1;
//Timer0 con periodo de 774,4u segundo.
// Fs = 1291,32 Hz.
//Corrimiento continuo de la seal x[n]
for( i=M-1; i!=0; i-- )x[i]=x[i-1];
//Adquisicin de una muestra de 10 bits en, x[0].
x[0] = (float)(ADC_Read(0)-512.0);
//Convolucin contina.
y0 = 0.0; for( i=0; i<M; i++ ) y0 += h[i]*x[i];
//Reconstruccin de la seal: y en 10 bits.
YY = (unsigned int)(y0+512.0);
PORTC = (YY>>8)&3;
PORTB = YY&255;
PORTC.F7=0;
INTCON.F2=0;
}
}
void main( void )
{
//Inicio del puerto B como salida.
TRISB = 0;
PORTB = 0;
TRISC = 0;
PORTC = 0;
//Se configura el TIMER 0, su interrupcin.
INTCON = 0b10100000;
T0CON = 0b11000101;
while(1)//Bucle infinito.
{
}
}

También podría gustarte