4) The same single-buffer TDM frame interface is used
An AD1847/ADSP-2181 loopback
example using a single index
register for SPORT autobuffering
Last Modified: 05/06/97
This Edition of Analog Devices Engineer’s Note will
provide some insight into interfacing the AD1847
SoundPort Codec to an ADSP-2181 using a single index
register for transmitting and receiving data via SPORT
autobuffering ad1847. The code was tested using an
AD1847 codec on our ADSP-21XX EZ-KIT-LITE
Evaluation Board. The example talkthru program uses the
AD1847’s 1 wire mode for transmitting and receiving of
data in slots 0-5. The supplied listing contains the
following for the 1-wire, talkthru example:
ADSP 2181 initialization
both for initialization and operation.
5) The initialization commands now come from program
memory rather than data memory. In a real-time
application, this saves the bother of initializing a data
memory array.
6) Since only the SPORT0 interrupt can be active during
initialization, the control flag is passed in the AF register
rather than in a variable.
7) Only the SPORT0 RX interrupt is used, never the TX.
In addition, the SPORT0 RX interrupt vector is altered
after initialization for maximum speed & flexibility.
ADSP 1847 Codec initialization
Interrupt service routines
Changes from the MIC2OUT.DSP version:
1) The ADI EZ-KIT-LITE version did not set the digital
mix control (a minor bug)
2) This version still takes two index registers to set up,
but only needs one index register to run. The EZ-KITLITE version requires three index registers for
initialization and two to run.
3) 1 wire mode is used for the SPORT interface. This
prevents simultaneous tx and rx autobuffer requests,
regardless of bus activity.
A single index interface to the AD1847 works because the
autobuffer transfers are always separated by at least one 16
bit time slot (about 4us at 8 kHz). Transmit autobuffers
happen at the beginning of a time slot, Rx autobuffers at
the end. Since the Tx slots come before the Rx slots,
there is never a conflict.
Note that this does not apply if two or more AD1847's are
cascaded. In such a system, hardware should be added to
allow a dummy time slot between the 6 slots used for
each AD1847. This still allows for up to four AD1847's
on one bus.
Note that the order here seems a little funny. The control field is
where
it is due to buffering in Sport0's transmitter. It is actually the
control
field that will be transmitted in the next frame.
---------------------------------------------------------------------------}
#define left_outbuf
#define right_out buf+1
#define control buf+2
#define status buf+3
#define left_in buf+4
#define right_in buf+5
EE-23Page 2
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
.init init_cmds:
0xc00600, {
Left input control reg
b7-6: 0=left line 1
1=left aux 1
2=left line 2
3=left line 1 post-mixed loopback
b5-4: res
b3-0: left input gain x 1.5 dB
}
0xc10600, {
Right input control reg
b7-6: 0=right line 1
1=right aux 1
2=right line 2
3=right line 1 post-mixed loopback
b5-4: res
b3-0: right input gain x 1.5 dB
}
0xc28800, {
left aux 1 control reg
b7 : 1=left aux 1 mute
b6-5: res
b4-0: gain/atten x 1.5, 08= 0dB, 00= 12dB
}
0xc38800, {
right aux 1 control reg
b7 : 1=right aux 1 mute
b6-5: res
b4-0: gain/atten x 1.5, 08= 0dB, 00= 12dB
}
0xc48800, {
left aux 2 control reg
b7 : 1=left aux 2 mute
b6-5: res
b4-0: gain/atten x 1.5, 08= 0dB, 00= 12dB
}
0xc58800, {
right aux 2 control reg
b7 : 1=right aux 2 mute
b6-5: res
b4-0: gain/atten x 1.5, 08= 0dB, 00= 12dB
}
0xc68000, {
left DAC control reg
b7 : 1=left DAC mute
b6 : res
b5-0: attenuation x 1.5 dB
}
0xc78000, {
right DAC control reg
b7 : 1=right DAC mute
b6 : res
EE-23Page 3
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
{============== S Y S T E M A N D M E M O R Y S T U F F ==============}
ax0 = b#0000111111111111; dm (DM_Wait_Reg) = ax0;
{ |+-/+-/+-/+-/+-/- ! IOWAIT0
|| | ! | !
|| | ! | !
|| | ! +------ | IOWAIT1
|| | ! |
|| | ! |
|| | +--------- ! IOWAIT2
|| | !
|| | !
|| +------------ | IOWAIT3
|| |
|| |
|+=============== ! DWAIT
| !
| !
+---------------- 0
}
mstat = b#1000000;
{ ||||||+- | Data register bank select
|||||+-- | FFT bit reverse mode (DAG1)
||||+--- | ALU overflow latch mode, 1=sticky
|||+---- | AR saturation mode, 1=saturate, 0=wrap
||+----- | MAC result, 0=fractional, 1=integer
|+------ | timer enable
+------- | GO MODE
}
{***********************************************************************
*******
*
* ADSP 1847 Codec initialization
*
* At this point, the rx autobuffer is already running, but w/o
interrupts
* enabled. I1,m1 operates a 3 byte auto-buffer for TX_BUF. We write
to
* TX0 here to start the tx autobuffer going.
*
* Every time the tx autobuffer wraps, an interrupt occurs that will
* clear STAT_FLAG
************************************************************************
*******}
idle;{ wait for a wrap }
ax0 = 0xc000; { start interrupt }
tx0 = ax0;
ar=14;
af = pass ar;{ interation count for tx int }
check_init:
af = pass af; { buffer to be sent to }
if ne jump check_init; { the codec }
check_aci1:
ax0 = dm(status); { once initialized, wait for codec }
ar = ax0 and 2; { to come out of auto-calibration }
if eq jump check_aci1; { wait for bit set }
check_aci2:
ax0 = dm (status); { wait for bit clear }
ar = ax0 and 2;
if ne jump check_aci2;
idle;
ar = 0x8600;
dm (control) = ar;{ un-mute left DAC }
idle;
ar = 0x8700;{ un-mute right DAC }
dm (control) = ar;
idle;
i4=^xecho;{ re-vector frame interrupt service routine }