Pseudo-code for the Baseband Frequency Compander


INITIALIZE
  Set TR_FLAG = RECEIVE (default)
  Initialize pointer EXPPTR to the EXP array

INPUT
  Obtain a new data point from the A/D converter
  Store it in the first position of the BUFFER array

FILTER #1
  Multiply all BUFFER elements with COEF1 elements
  Sum the results into ANSR1

FILTER #2
  If  TR_FLAG = TRANSMIT
    Complex multiply all BUFFER elements with COEF2T elements
    Sum the results into ANSR2
    Shift all elements of BUFFER down
  Else  (TR_FLAG = RECEIVE)
    Complex multiply all BUFFER elements with COEF2R elements
    Sum the results into ANSR2
    Shift all elements of BUFFER down
  Endif

SHIFT
  If TR_FLAG = TRANSMIT
    Complex multiply ANSR2 and an element from EXP (referenced by EXPPTR)
  Else  (TR_FLAG = RECEIVE)
    Complex divide ANSR2 by an element in EXP (referenced by EXPPTR) 
  Endif
  Store the result in ANSR2
  Increment EXPPTR pointer
  If EXPPTR is past Last_Element then
    Reset EXPPTR to First_Element

COMBINE
  Add the real part of ANSR2 to ANSR1
  Store the result in ANSR1

OUTPUT
  Send ANSR1 to the D/A converter
  Update the TR_FLAG  (Transmit/Receive)

Loop back to INPUT

Variables
---------
N = NUMTAPS+1 = Number of filter taps
L = LUPSIZE   = Number of elements in EXP array

Name      Dimension Type            Description
-------------------------------------------------------------------------------
COEF1     1 x N     Real            Filter #1 coefficients--same for Trans/Rec
COEF2T    2 x N     Real & Imag     Filter #2 coefficients for Transmitting
COEF2R    2 x N     Real & Imag     Filter #2 coefficients for Receiving
BUFFER    1 x N     Real            Buffer of previous inputs
EXP       2 x L     Real & Imag     Look-up table of exp(-j*2*pi*fo*t)
ANSR1     1 x 1     Real            Output of Filter #1, temporary variable
ANSR2     2 x 1     Real & Imag     Output of Filter #2, temporary variable 
EXPPTR    ---       Pointer         Pointer to elements in EXP array
TR_FLAG   boolean   (Trans/Rec)     Transmit/Receive flag

Fig 6 - Pseudo-code for the baseband frequency compander.