
AD6652
Internal Write Access
Up to 20 bits of data (as needed) can be written by the following
process. Any high order bytes that are needed are written to th
corresponding data registers defined in the external mem
map 3-bit address space. The least significant byte is then
written to D
Rev. 0 | Page 72 of 76
e
ory
R0 at Address (000). When a write to DR0 is
detected, the internal microprocessor port state machine then
moves the data in DR2–DR0 to the internal address pointed to
by the address in the channel address register (CAR) and access
control register (ACR).
ite Pseudocode
void write_micro(ext_address, int data);
main();
{
/* This code shows the programming of the NCO
phase offset register using the write_micro
function as defined above. The variable address is
the External Address A[2:0] and data is the value
to be placed in the external interface register.
Internal Address = 0x087
*/
// holding registers for NCO phase byte wide
access data
int d1, d0;
// NCO frequency word (16 bits wide)
NCO_PHASE = 0xCBEF;
// write ACR
write_micro(7, 0x03 );
// write CAR
write_micro(6, 0x87);
// write DR1 with D[15:8]
d1 = (NCO_PHASE & 0xFF00) >> 8;
write_micro(1, d1);
// write DR0 with D[7:0]
// On this write all data is transferred to the
internal address
d0 = NCO_FREQ & 0xFF;
write_micro(0, d0);
} // end of main
Internal Read Access
A read is performed by first writing the channel address register
(CAR) and ACR as with a write. The data registers (DR2–DR0)
are then read in the reverse order that they were written. First,
the least significant byte of the data (D[7:0]) is read from DR0.
On this transaction, the high bytes of the data are moved from
e internal address pointed to by the CAR and ACR into the
remaining data registers (DR2–DR1). This data can then be
read from the data registers using the appropriate 3-bit
addresses. The number of data registers used depends solely on
the amount of data to be read or written. Any unused bit in a
data register should be masked out for a read.
Read Pseudocode
int read_micro(ext_address);
main();
{
/* This code shows the reading of the first RCF
coefficient using the read_micro function as
defined above. The variable address is the
External Address A[2..0].
Internal Address = 0x000
*/
// holding registers for the coefficient
int d2, d1, d0;
// coefficient (20-bits wide)
long coefficient;
// write ACR
write_micro(7, 0x00 );
// write CAR
write_micro(6, 0x00);
/* read D[7:0] from DR0, All data is moved from
the internal registers to the interface registers
on this access */
d0 = read_micro(0) & 0xFF;
// read D[15:8] from DR1
d1 = read_micro(1) & 0xFF;
// read D[23:16] from DR2
d2 = read_micro(2) & 0x0F;
coefficient = d0 + (d1 << 8) + (d2 << 16);
} // end of main
Wr
th