8 Analog Interface
8 – 14
An autobuffering example program is shown in Listing 8.2.
{ ADSP-21msp58/59 Analog Interface Autobuffer Example }
{ - configures analog interface
}
{ - enables analog autobuffer
}
{ - receive analog data into a 256 word buffer
}
{ - transmit analog data from a 256 word buffer
}
.MODULE/RAM/ABS=0/BOOT=0 auto_example;
.VAR/DM/CIRC buff1[256];
{first data buffer}
.VAR/DM/CIRC buff2[256];
{second data buffer}
.VAR/DM flag_bit;
{tracks buffers}
#define
codec_tx_data
0x3FEC
#define
codec_rx_data
0x3FED
#define
codec_ctrl_reg 0x3FEE
#define codec_auto_ctrl 0x3FEF
resetv:
JUMP setup; NOP; NOP; NOP;
irq2v:
RTI; NOP; NOP; NOP;
{interrupt vectors ...}
hipwv:
RTI; NOP; NOP; NOP;
hiprv:
RTI; NOP; NOP; NOP;
spt0tv:
RTI; NOP; NOP; NOP;
spt0rv:
RTI; NOP; NOP; NOP;
antv:
RTI; NOP; NOP; NOP;
anrv:
JUMP switch; NOP; NOP; NOP;
{call autobuffer switch}
irq1v:
RTI; NOP; NOP; NOP;
irq0v:
RTI; NOP; NOP; NOP;
timerv:
RTI; NOP; NOP; NOP;
pwrdwnv:
RTI; NOP; NOP; NOP;
Before autobuffering is enabled, separate circular buffers must be set
up in data memory for the ADC receive and DAC transmit data. This
is accomplished by selecting I (index) and M (modify) registers in the
analog autobuffer/powerdown register; see Figure 8.5.
Transmit data autobuffered to the DAC is addressed with the I register
specified in the ATIREG field (bits 9, 10, 11). Receive data autobuffered
from the ADC is addressed with the I register specified in the ARIREG
field (bits 4, 5, 6). The modify (M) registers are specified in the
ARMREG (bits 2, 3) field and ATMREG (bits 7, 8) field. Since the
transfer of ADC and DAC data occurs simultaneously, it is possible to
use the same I register for transmit and receive autobuffering. In this
case, the buffer is shared for both functions and care should be taken
when specifiying a value for the M register.