/************************************************************************/ /* Delta.C 2/23/95 */ /* */ /************************************************************************/ /* */ /* This program uses delta modulation to encode quantized data */ /* from a codec. The bit rate can be effectively changed by */ /* changing the value at which the error signal saturates. */ /* */ /* This program defines the port addressses for the */ /* particular input and output channel being used, sets up the */ /* IRQ3 to call the delta-modulation routine, and sets up */ /* an idle wait loop to conserve power while waiting for the */ /* interrupt. */ /************************************************************************/ #include <21020.h> /* For the idle() command */ #include /* For the interrupt command */ #include /* For the segment function */ #include #define MAX_DIFF 32 volatile int in_port segment(hip_reg0); /* hip_reg0, hip_reg2, hip_reg3 are */ volatile int out_port segment(hip_reg2);/* used in architecture file */ volatile int out_port2 segment(hip_reg3); int current, previous; /*current and previous samples */ int received; /* reconstructed signal value */ int first_sample; /* flag: is this the first sample? */ void process_input(int); void main(void) { first_sample = 1; interrupt(SIG_IRQ3, process_input); while (1) { idle(); } } void process_input(int sig_number) { int diff; /* if this is the first sample, set received signal to xmit signal */ if (first_sample) { current = in_port; previous = current; received = current; out_port = current; first_sample = 1; } else { current = in_port; diff = current - previous; if (abs(diff) > MAX_DIFF) if (diff < 0) received = received - MAX_DIFF; else received = received + MAX_DIFF; out_port = received; out_port2 = diff; } }