So I started to attempt to write the I2C send routine that will communicate with a 14 bit, AD5647R DAC. I have encountered a problem where the high bit for the data is missing the front 2 zeroes after I split the incoming value. I have done this as shown below. Any ideas? Also still haven't managed to get the read function to work... edit->It is working with the code below now
void sendIIC (int output)
{
byte dataDAC[2];
unsigned char MAX_delay = 100;
unsigned int count;
dataDAC[0] = (output>>8) & 0x00FF; // High
dataDAC[1] = (output) & 0x00FF; // Low
IICC_IICEN = 1; // IIC enabled
IICC_TX = 1; // Set Transmit
IICC_MST = 1; // Set START
// Send address. LSB decides on R or W
while(IICS_TCF == 0);
IICD = 0x1E; // Address -> 0001111, LSB for receive -> 0
for (count=0; count<MAX_delay;count++) asm("nop");
// Send Command byte
while(IICS_TCF == 0);
IICD = 0x1F; // Command: R->0 ,S->0 ,Command->011 (Write to and update DAC n) ,DAC Address->111 (Both DACs)
for (count=0; count<MAX_delay;count++) asm("nop");
// Send high data byte
while(IICS_TCF == 0);
IICD = dataDAC[0]; // Send the high bits
for (count=0; count<MAX_delay;count++) asm("nop");
// Send low data byte
while(IICS_TCF == 0);
IICD = dataDAC[1]; // Send the low bits
for (count=0; count<MAX_delay;count++) asm("nop");
IICC = 0x80;
}