Skip to content

Arduino Library for LTC6904, I2C Programmable Oscillator

License

Notifications You must be signed in to change notification settings

FaultyTwo/LTC6904-arduino-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LTC6904

Arduino Library for LTC6904, 1kHz to 68MHz I2C Programmable Oscillator.

For more technical details, please refer to the datasheet.

How To Use The Library

Include the library, then simply create an object according to each device address, like this:

#include <LTC6904.h>
LTC6904 clk(0x16);
LTC6904 clk2(0x17);

To use this library with other I2C ports, you can simply create a TwoWire object then parse it into the 'begin' function:

// ESP32
#define I2C_SDA 33
#define I2C_SCL 32

TwoWire esp = TwoWire(0);
LTC6904 clk(0x16);

void setup(){
  esp.begin(I2C_SDA, I2C_SCL, 1000000);
  clk.begin(&esp);
}

Methods

void begin(TwoWire &wire = Wire);

Initiate the LTC6904 library.

Can be configured to use other I2C ports from a 'TwoWire' object.
For default I2C port, just leave the parameter blank.

void setFreq(float freq, uint8_t power)

Set frequency value of LTC6904.

  • 'freq': The frequency value in decimal.
  • 'power': The exponential value by the power of 10.

Ex. 6.83 KHz -> setFreq(6.83,3);
(6.83x10^3)
Ex. 12.54 MHz -> setFreq(12.54,6);
(12.54x10^6)

^If the value is lower than 1kHz, the value will be set back to 1kHz instead.
^If the value is higher than 68MHz, the value will be set back to 68MHz instead.

void setOct(uint8_t oct)

Set the 'OCT' parameter.
^'OCT' shouldn't exceed 15, otherwise will be set back to 15.

void setDac(unsigned short dac)

Set the 'DAC' parameter.
^'DAC' shouldn't exceed 1023, otherwise will be set back to 1023.

void outputConfig(uint8_t _CNF)

Configure outputs of LTC6904.

_CNF value CLK ~CLK
0x00 CLK CLK + 180
0x01 OFF ON
0x02 ON OFF
0x03 Powered-down Powered-down

^Beyond than 0x03 will set output back to 0x00

uint8_t getOct()

Get the 'OCT' value

unsigned short getDac()

Get the 'DAC' value

uint8_t getCNF()

Get the 'CNF' value