LTC6904 is a programmable oscillator which is capable of generating frequencies from 1kHz to 68MHz. The oscillation frequency can be changed via the I2C interface and thus makes it very easy to interfacing with MCUs.

According to the data sheet, the output frequency is determined by the OCT and DAC bits in the 16 bit serial port register. For a given frequency, the register bits can be obtained by:

\[OCT=Trunc\left( 3.322\cdot log{\frac{f}{1039}}\right) \]
\[DAC=Round\left( 2048 – \frac{2078\cdot2^{(10+OCT)}}{f}\right) \]

The following code shows the implementation using Arduino.

#include <Wire.h>
#include <math.h>

const byte I2C_ADDR_0 = 0x17;
const byte I2C_ADDR_1 = 0x16;

byte i2cAddress = I2C_ADDR_0;

//set oscillation frequency
//freq: frequency in kHz
//compOutputOn: whether the complementary clock output is enabled
//register format: 
void setFreq(float freq, boolean compOutputOn=true) 
  unsigned int oct = (int) (3.322*log10(freq * 1000.0 / 1039.0));
  unsigned int dac = (int) (2048.0 - 2078.0 * pow(2, 10 + oct) / (freq * 1000.0) + 0.5);
  unsigned int cnf = compOutputOn ? 0 : 2;
  unsigned int reg = oct << 12 | dac << 2 | cnf;
  byte high = (reg >> 8) & 0xff;
  byte low = reg & 0xff;

void setup()
  setFreq(23.0); //set frequency to 23.0 kHz

void loop()

LTC6903 offers the same frequency range as LTC6904 except that it is controlled via SPI.

Be Sociable, Share!

7 Thoughts on “Interfacing LTC6904 With Arduino”

  • Hi Kerry,

    I am going to use this chip and integrate it with arduino. Could you please upload a schematic of the circuit you used as well?
    Thank you.

    • Hi Arslan,

      There really isn’t anything special about the schematic though, you only need to connect the chip SCL pin to Arduino’s analog input 5, SDA pin to Arduino’s analog input 4 and connect the ground together. The chip can be either powered from the 5V on the Arduino board or using a separate power supply.

  • Hi Kerry,
    Thank you so much for your reply and answering my naive question. What kind of frequency are you able to generate via this chip? I have ordered mines and waiting for it. Meanwhile it would be good to know what is the step size of the frequency? Are you able to generate for example, 6.56Mhz and then changing the register values to get 6.57Mhz?

    thanks once again

    • Hi Arslan,

      The output frequency of LTC6904 is determined by f=2^oct*2078/(2-dac/1024) (see data sheet), where 0<=oct<=15 and 0<=dac<=1023. The smallest frequency spacing is achieved when oct=0 and dac is 0 and 1. So at the highest resolution (lowest frequency) the step is around 0.5Hz and the step between the two highest frequencies (oct=15 dac=1022 and 1023) is around 200 kHz.

  • Hi Kerry,

    How do I make sure that its running at the desired frequency. I don’t have frequency counter or oscilloscope.
    I tried to do I2c read , but no use, it always returns the same value.
    please help!

Leave a Reply

Your email address will not be published.