SparkFun Clock Generator 5P49V60 (Qwiic) Hookup Guide
Example 6: Multiplex Clock Output
Finally in this last example, the many ways that a clock frequency can be multiplexed through software is demonstrated. Click on File > Examples > SparkFun Clock 5P49V60 Arduino Library > Example6_mux_clock_output to open the example. If, for example, you wanted a lower frequency than the lowest possible frequency output of the frequency output dividers (1MHz), then you can pipe an already low frequency to another divider to get even lower frequencies. Or, if you've set one divider and want that frequency piped out of each output rather than setting each divider, this can also be done. Let's look at the code below.
This example has been reduced to the relevant code block. The first two examples have already demonstrated how to import the correct libraries and connect to the microcontroller to the SparkFun Clock Generator over its default address 0x6A
. After setting the internal VCO to 1600MHz, its frequency is piped to the output divider of clock one with clockGen.muxPllToFodOne()
. What's important to note is that these values are set manually as in Example 3 because using the more abstract function of clockGen.setClockOne()
assumes your piping the VCO frequency to a frequency output divider and NOT, as in this example, piping the output to another frequency output divider.
language:c
clockGen.setVcoFrequency(1600.0); // Give float value in MHz.
language:c
// Clock One -----------------------------------------------------
// To get 16MHz Output = (1600MHz/2)/16MHz = 50
clockGen.setIntDivOutOne(50);
Serial.print("FOD One Integer Divider: ");
Serial.println(clockGen.readIntDivOutOne());
clockGen.muxPllToFodOne();
// There are many OUTPUT modes available for each clock - this example uses
// LVPECL (Low voltage Positive Emitter Coupled Logic) mode and terminates
// the clock with a 100Ohm resistance to GND.
clockGen.clockOneConfigMode(LVPECL_MODE);
clockGen.clockOneControl(ENABLE);
// --------------------------------------------------------------
With clock two we see something different. The function clockGen.muxFodOneToFodTwo()
takes the output of the frequency output divider for clock one and pipes it to the frequency output divider of clock two. Now this demonstrates its function but doesn't actually divide it a second time.
language:c
// Clock Two -----------------------------------------------------
// This function call multiplexes the settings from Clock One's Output
// Divider to the Output Divider of Clock Two. In this way you can divide a
// low frequency to get even lower frequencies. The settings for the Clock Two are
// set to zero so will output a 16MHz frequency.
clockGen.muxFodOneToFodTwo();
clockGen.clockTwoConfigMode(LVPECL_MODE);
clockGen.clockTwoControl(ENABLE);
// --------------------------------------------------------------
Finally, with clock three the output of clock two is piped to clock three's output, resulting in a round about way of getting three clock outputs to 16MHz. It would have been easier to use the relevant functions to pipe the first output to the next three outputs.
language:c
// Clock Three -----------------------------------------------------
// This function call multiplexes the output from clock two to the output of
// clock three. If you want to duplicate a signal this may be the best
// option. Notice that you don't need to enable clock three to see an output
// on this line.
clockGen.muxOutTwoToOutThree();
clockGen.clockThrConfigMode(LVPECL_MODE);
// --------------------------------------------------------------
}
void loop(){
delay(1000);
}
To summarize there are three avenues that you can multiplex frequencies with the SparkFun Clock Generator. The first is to take the VCO frequency and pipe that to the any of the frequency output dividers. Secondly, you can take the output of the frequency output dividers and pipe them to a the next sequential frequency output divider: FOD1 -> FOD2 -> FOD3 -> FOD4. Finally you can pipe the output of a frequency output divider to any of the next sequential clock outputs: Clock 1 -> Clock 2 -> Clock 3 -> Clock 4.