First page Back Continue Last page Graphics
Interrupt Service Routine (continued)
- //------------------------------------------------
- // Digital IIR Filter "Temp" divided by 2^8
- // MS Byte must be all FF's or all 00's
- // (max value <2^24 which is 16,777,216)
- // nominal value 8,192*425 (larger coef) = 3,481,600
- //------------------------------------------------
- p_Temp = (BYTE*)&Temp;
- p_Temp[0] = p_Temp[1];
- p_Temp[1] = p_Temp[2];
- p_Temp[2] = p_Temp[3];
- //------------------------------------------------
- // Input summation
- //------------------------------------------------
- Intermediate = Input - Temp;
- //------------------------------------------------
- // Digital IIR Filter delay
- //------------------------------------------------
- Intermediate2 = Intermediate1;
- Intermediate1 = Intermediate;
- //------------------------------------------------
- // Digital FIR Filter (IIR Filter output summation)
- //------------------------------------------------
- Output = Intermediate-Intermediate2;
- Because “Temp” is a partial product sum of intermediate values inflated by 256, after the multiply we immediately divide “Temp” by 256. Since this is 8 bits, we do a byte shift rather than performing a divide. “p_Temp” is merely used as a pointer to the 4 byte “Temp” variable.
- No attempt is made to bit shift the MS bit of the MS byte of “Temp”. As long as the max value is <16,777,216, the MS byte would be all 00’s or all FF’s anyway.
- Completing the digital filter is trivial …
- Compute a new intermediate
- Transfer (delay) prior intermediate outputs
- Compute output