/********************************************************** Example program I2C-OSC interface with Arduino. SETUP: I2C-OSC => Arduino PIN2 => A4, PIN3 => A5, PIN4 => ground, PIN8 => +5V Note: The program is written for address 0x2E (Arduino address 0x17). This program was tested using Arduino Nano Document: LTC6904 datasheet Updated: September 4, 2008 E-mail: support@gravitech.us Gravitech (C) Copyright 2008 All Rights Reserved **********************************************************/ #include void setup() { Serial.begin(9600); Wire.begin(); // join i2c bus (address optional for master) delay(1000); } void loop() { const byte I2C_WR = 0x17; // I2C write address byte DAT0; // I2C high byte data byte DAT1; // I2C low byte data byte i; // Counter for (i=0; i<2; i++) { if (i==0) { /* Set I2C-OSC to 128kHz */ // Looking at the table on datasheet page 7, we need to set OCT = 6 for 66.5kHz to 132.9kHz // Looking at the datasheet on page 6 and calculate DAC value = 984 (0x3D8) for 128kHz DAT1 = 0x6F; DAT0 = 0x60; // CNF1 = 0 and CNF0 = 0 } // end if else { /* Set I2C-OSC to 256kHz */ // Looking at the table on datasheet page 7, we need to set OCT = 7 for 133Hz to 265.7kHz // Looking at the datasheet on page 6 and calculate DAC value = 984 for 256kHz DAT1 = 0x7F; DAT0 = 0x60; // CNF1 = 0 and CNF0 = 0 } // end else Wire.beginTransmission(I2C_WR); Wire.send(DAT1); Wire.send(DAT0); Wire.endTransmission(); delay (2000); } // end for }