Example Program: Interrupt Routine Discussion - Analog Devices adsp-2100 Manual

Adsp-2100 family programmable single-chip microprocessors
Table of Contents

Advertisement

SPORT0 is set up to generate the serial clock internally at 1.536 MHz,
based on a processor clock rate of 12.288 MHz. The RFS and TFS signals
are both required and the RFS signal is generated internally at 8 kHz,
while the TFS signal comes from the external device communicating with
the processor.
Finally, SPORT0 is enabled and the interrupts are enabled. Now the IDLE
instruction causes the processor to wait for interrupts. After the return
from interrupt instruction, execution resumes at the instruction following
the IDLE instruction. Once these setup instructions have been executed,
all further activity takes place in the interrupt service routine, shown in
Listing 12.2.
.MODULE/ROM fir_routine;
.INCLUDE
<const.h>;
.ENTRY
fir_start;
.EXTERNAL data_buffer, coefficient;
{interrupt service routine code}
FIR_START:
CNTR = taps_less_one;
SI = RX0;
DM(I0,M0) = SI;
MR=0, MY0=PM(I4,M4), MX0=DM(I0,M0);
DO convolution UNTIL CE;
convolution: MR=MR+MX0*MY0(SS), MY0=PM(I4,M4), MX0=DM(I0,M0);
MR=MR+MX0*MY0(RND);
TX0 = MR1;
RTI;
.ENDMOD;
Listing 12.2 Interrupt Routine
12.2.2

Example Program: Interrupt Routine Discussion

This subroutine transfers the received data to the next location in the
circular buffer (overwriting the oldest sample). All samples and
coefficients are then multiplied and the products are accumulated to
produce the next output value. The subroutine checks for overflow and
saturates the output value to the appropriate full scale, then writes the
result to the transmit section of SPORT0 and returns.
The first four lines of the listing declare the code module (which is
relocatable rather than placed at an absolute address), include the same
file of constants, and make the entry point visible to the main routine with
the .ENTRY directive. Likewise, the .EXTERNAL directive makes the
main routine labels visible in the interrupt routine.
Programming Model
{relocatable FIR interrupt module}
{include constant declarations}
{make label visible outside module}
{make globals accessible in module}
{N-1 passes within DO UNTIL}
{read from SPORT0}
{transfer data to buffer}
{set up multiplier for loop}
{CE = counter expired}
{Nth pass with rounding}
{write to sport}
{return from interrupt}
12
{MAC these, fetch next}
12 – 11

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents