Skip to content

A MicroPython and CircuitPython library for controlling the si5351 chip - with quadrature support!

Notifications You must be signed in to change notification settings

roseengineering/silicon5351

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 

Repository files navigation

silicon5351

A MicroPython and CircuitPython library for controlling the SI5351 chip.

Introduction

The file silicon5351.py contains the actual si5351 library. Inside the library is the SI5351_I2C class for controlling the Silicon Labs SI5351x range of chips.

This class also supports the quadrature output feature of the chip. The lowest frequency that can be generated in quadrature is limited by the chip hardware to clock's PLL frequency divided by 128.

Example

from silicon5351 import SI5351_I2C

import sys
if sys.implementation.name == 'circuitpython':
    import board, busio
    # i2c = busio.I2C(scl=board.SCL, sda=board.SDA) # XIAO RP2040
    i2c = busio.I2C(scl=board.GP5, sda=board.GP4)   # PICO
    while not i2c.try_lock():
        pass
else:
    import machine
    i2c = machine.I2C(1, scl=machine.Pin(7), sda=machine.Pin(6))

crystal = 25e6     # crystal frequency
mul = 15           # 15 * 25e6 = 375 MHz PLL frequency
freq = 3.0e6       # output frequency with an upper limit 200MHz
quadrature = True  # lower limit for quadrature is 375MHz / 128
invert = False     # invert option ignored when quadrature is true

si = SI5351_I2C(i2c, crystal=crystal)
si.setup_pll(pll=0, mul=mul)
si.init_clock(output=0, pll=0)
si.init_clock(output=1, pll=0, quadrature=quadrature, invert=invert)
si.set_freq_fixedpll(output=0, freq=freq) 
si.set_freq_fixedpll(output=1, freq=freq) 
si.enable_output(output=0)
si.enable_output(output=1)
print(f'done freq={freq} mul={mul} quadrature={quadrature} invert={invert}')

The library calls the PLL soft reset function of the chip whenever the MultiSynth whole number portion of the divisor changes or is intitialized. This soft reset is required in order to generate a quadrature or an inverted output. It is also required to synchronize all outputs derived off a particular PLL and be coherrent with respect to each other.

API

class silicon5351.SI5351_I2C(self, i2c, crystal, load=3, address=96)
Instantiate the SI5353_I2C class. All clock outputs (clkouts) will be shutdown and disabled.
i2c The MicroPython or CircuitPython I2C object.
crystal The crystal frequency in Hz.
load The load capacitance of crystal. Must use one of the global constants defined in the library for this value.
address The I2C address of the si5351 chip.

Instances of the silicon5351.SI5351_I2C class have the following public properties and methods:

SI5351_I2C.init_clock(self, output, pll, quadrature=False, invert=False, drive_strength=3)
Initialize the given clock output (clkout). This method must be called before using set_freq_fixedpll() on the output. It makes no calls to the Si5351. It only intializes the output clock's state within the library.
output The number of the clock output (clkout) to initialize
pll The number of the PLL to select. (0=PLLA, 1=PLLB)
invert Invert the output.
quadrature Invert the output and also enable quadrature logic in the library.
drive_strength The drive strength in current to use for the output. Must use one of the global constants defined in the library for this value.

SI5351_I2C.enable_output(self, output)
Enable the given clock output (clkout).
output The clock output (clkout) to enable.

SI5351_I2C.disable_output(self, output)
Disable the given clock output (clkout).
output The clock output (clkout) to disable.

SI5351_I2C.setup_pll(self, pll, mul, num=0, denom=1)
Set the frequency for the given PLL. The PLL frequency is set to the frequency given by (mul + num / denom) times the crystal frequency.
pll The number of the PLL to select. (0=PLLA, 1=PLLB)
mul The whole number to multiply the crystal frequency by. This value must be in the range [15-90].
num The numerator to multiply the crystal frequency by. This value must be in the range [0-1048574].
denom The denominator to multiply the crystal frequency by. This value must be in the range [1-1048575].

SI5351_I2C.setup_multisynth(self, output, div, num=0, denom=1, rdiv=0)
Set the multisynth divisor of the PLL frequency.
output The number of the clock output (clkout) to set the frequency for.
div The whole number divisor to set the multisynth to. This value must be in the range [4-2047]
num The numerator to divide the pll frequency by. This value must be in the range [0-1048574].
denom The denominator to divide the pll frequency by. This value must be in the range [1-1048575].
rdiv The Rx divisor in log base 2 for additional vco division.

SI5351_I2C.set_freq_fixedpll(self, output, freq)
Set the frequency for the clock output (clkout) by changing the multisynth divisors. Must call init_clock() and setup_pll() before calling this method.
output The number of the clock output (clkout) to set the frequency for.
freq The frequency in Hz to set the clock output (clkout) to.

SI5351_I2C.set_freq_fixedms(self, output, freq)
Set the clock output (clkout) to the requested frequency by changing the pll multiplier value. Must call init_clock() and setup_multisynth() before calling this method.
output The number of the clock output (clkout) to set the frequency for.
freq The frequency in Hz to set the clock output (clkout) to.

SI5351_I2C.disabled_states(self, output, state)
Set the state of the clock outputs (clkout) when one or more clocks are disabled either in software or as a result of the output enable (OEB) pin going active. The possible disabled states for an output are low voltage, high voltage, high impedance, and never disabled.
output The clock output (clkout) to set the disabled state for.
state The disabled state to set for the clock output (clkout). Must use one of the global constants defined in the library for this value.

SI5351_I2C.disable_oeb(self, mask)
Disable the output enable (OEB) pin for the given clock outputs (clkouts).
mask A bit mask of the clock outputs (clkouts) to disable output enable (OEB) pin support for.

About

A MicroPython and CircuitPython library for controlling the si5351 chip - with quadrature support!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages