SparkFun Clock Generator 5P49V60 (Qwiic) Hookup Guide

Pages
Contributors: Elias The Sparkiest
Favorited Favorite 2

Example 2: Generate Multiple Clocks

This example does exactly what the first example does but demonstrates how to also turn on other clock outputs. Click on File > Examples > SparkFun Clock 5P49V60 Arduino Library > Example2_generate_multiple_clocks. This example reinforces how the voltage controlled oscillator frequency is piped to each of the frequency output dividers of the clocks. This doesn't always have to be the case, you can pipe the output of the frequency output divider of one clock to a different output divider to get lower frequencies! Remember that 1MHz is the lowest possible output (clock output frequencies) of any of the frequency output dividers, unless you use this method. Check out example 6 below for more information!

language:c
#include <Wire.h>
#include "SparkFun_5P49V60.h"

// Uses default address at 0x6A, alternate available at 0x68
SparkFun_5P49V60 clockGen;

void setup(){

  Wire.begin();
  Serial.begin(115200);

  if (clockGen.begin() == true){
    Serial.println("Clock Generator Ready.");
  }
  else {
    Serial.println("Could not communicate with the SparkFun Clock Generator.");
    while(1);
  }

  // Fist, Setting the internal oscillator to a known value. 
  Serial.println("Setting Internal Clock Frequency to 1600MHz.");
  clockGen.setVcoFrequency(1600.0); // Give float value in MHz 

After connecting to the SparkFun Clock Generator, the internal clock frequency of the voltage controlled oscillator is set to 1600MHz (1.6GHz). This frequency can then be fed to the frequency output dividers of the clock outputs. This is done with clockGen.muxPlltoFodOne() and clockGen.muxPlltoFodTwo() which tells the IC to send the VCO frequency to the frequency output divider of clock one and two respectively. Next the output mode is set to LVPECL_MODE (low voltage positive emitter coupled logic) with clockGen.clockOneConfigMode(LVPECL_MODE) and clockGen.clockTwoConfigMode(LVPECL_MODE).

language:c
  // Clock One----------------------------------------------------
  // Use internal phase lock loop for clock output calculation.
  clockGen.muxPllToFodOne();
  Serial.println("Setting Output Mode for Clock One to LVPECL.");
  // There are many OUTPUT modes available for each clock - this example uses
  // LVPECL (Low voltage Positive Emitter Coupled Logic) mode.
  clockGen.clockOneConfigMode(LVPECL_MODE);
  Serial.println("Setting Clock One Frequency to 8MHz.");
  clockGen.setClockOneFreq(8.0); // Give float value in MHz, 8.0 = 8000000Hz or 8MHz
  // --------------------------------------------------------------

  // Clock Two--------------------------------------------------
  // Use internal phase lock loop for clock output calculation.
  clockGen.muxPllToFodOne();
  Serial.println("Setting Output Mode for Clock Two to LVPECL.");
  clockGen.clockTwoConfigMode(LVPECL_MODE);
  Serial.println("Setting Clock Two Frequency to 16MHz.");
  clockGen.setClockOneFreq(16.0); // Give float value in MHz, 16.0 = 16000000Hz or 16MHz
  // -----------------------------------------------------------

}

void loop(){
  delay(1000); 
}

Finally, clock one has its frequency set to 8MHz and clock two to 16MHz.