AnsweredAssumed Answered

GT16A I2C interface with MAX1069

Question asked by Oliver Hobson on Apr 16, 2013
Latest reply on Jun 12, 2013 by Monica Arvizu

Hi,

 

I am trying to use the I2C interface for the first time and am unsure of my code. I am using the GT16A as a master and am attempting to read data from the MAX1069 14 bit ADC IC. Below is my I2C initialising function and the read function. I am not getting the results I expected and I am unsure why. Any help will be greatly appreciated! edit->Turns out I forgot the pull-up resistors, but I still can't get the ADC to function correctly..

 

   int receiveIIC (void) // Thermistor ADC - MAX1069    {     byte dataADC[2] ;     int result;     unsigned char MAX_delay = 100;     unsigned int count;          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 = 0x61;  // Address -> 0110000, LSB for receive -> 1 = 0x61          // Address -> 0110000, LSB for receive -> 0 = 0x60    for (count=0;count<MAX_delay;count++) asm("nop");           while(IICS_TCF == 0);     IICC_TX = 0;          dataADC[0] = IICD; // Receive first byte      for (count=0; count<MAX_delay;count++) asm("nop");     while(IICS_TCF == 0);          IICC_TXAK = 1;  // Send No Acknowledge     dataADC[1] = IICD; // receive second byte     for (count=0; count<MAX_delay;count++) asm("nop");     while(IICS_TCF == 0);          IICC = 0x80;              result = dataADC[0] << 8;          result += dataADC[1];                            return result;     }

Outcomes