AD6654
Rev. 0 | Page 67 of 88
PROGRAMMING INDIRECT ADDRESSED REGISTERS
USING SERIAL PORT
This section gives examples for programming CRCF coefficient
RAM (with an indirect addressing scheme) using the serial port
(either SPI or SPORT modes). Though the following specific
examples are for CRCF coefficient RAM programming, they can
be extended to other indirect addressed registers like DRCF
coefficient RAM. There are four possible programming scenarios,
and examples are given for all scenarios using two commands:
SerialWrite(data) and SerialRead. These commands signify an 8-
bit write to, or an 8-bit read from, the serial port (SPI or SPORT).
SerialWrite(8-bit number):
is an 8-bit write to SPI or SPORT. In
SPI mode, the SCLK is toggled eight times while SCS is pulled low.
In SPORT mode, SCS is pulled low, SRFS is held high for one
SCLK cycle, and eight bits of data are shifted into the SDI pin
following the SRFS pulse. Though the 8-bit number argument
shown in the following code is always shown MSBFIRST, it is
written with MSB shifting into the device first in MSBFIRST
mode, and it is written with LSB shifting into the device first in
LSBFIRST mode.
SerialRead():
is an 8-bit read from the SDO pin in SPI or SPORT
modes. In SPI mode, the SCLK toggles eight times while SCS is
low. In SPORT mode, SCS is pulled low, STFS is held high for one
SCLK cycle, and then the eight bits of data that shifted out on
SDO following the STFS pulse are read. The data shifted out
should be interpreted based on the polarity of the MSBFIRST pin.
MSBFIRST Mode Using Single Byte Block Transfers
SerialWrite(0x98); //CRCF Start Address
SerialWrite(0x01);
SerialWrite(0x00);
SerialWrite(0x99); //CRCF Final Address
SerialWrite(0x01);
SerialWrite(N-1);
//N is the number of coefficients
for (i=0 ; i < N; i++) {
//writing registers
SerialWrite(0x9E);
//MSB written first
SerialWrite(0x01);
//data bits[23:16]
SerialWrite(coeff[i] >> 16 & 0xFF);
SerialWrite(0x9D);
SerialWrite(0x01);
//data bits[15:8]
SerialWrite(coeff[i] >> 8 & 0xFF);
SerialWrite(0x9C);
//LSB written last
SerialWrite(0x01);
//data bits[7:0]
SerialWrite(coeff[i] & 0xFF);
}
SerialWrite(0x98); //CRCF Start Address
SerialWrite(0x01);
SerialWrite(0x00);
SerialWrite(0x99); //CRCF Final Address
SerialWrite(0x01);
SerialWrite(N-1);
//N is the number of coefficients
for (i=0 ; i < N; i++) {
//reading registers
SerialWrite(0x9E);
//MSB readback first
SerialWrite(0x81);
//data bits[23:16]
Coeff[i] = SerialRead() << 16;
SerialWrite(0x9D);
SerialWrite(0x81);
//data bits[15:8]
Coeff[i] |= SerialRead() << 8;
SerialWrite(0x9C);
//LSB readback last
SerialWrite(0x81);
//data bits[7:0]
Coeff[i] |= SerialRead();
}