Skip to content

Commit 6bd9674

Browse files
authored
Merge pull request #55 from etherkit/v2.1.0
V2.1.0
2 parents 252d1ee + 9c8fd06 commit 6bd9674

File tree

6 files changed

+204
-65
lines changed

6 files changed

+204
-65
lines changed

README.md

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ There will be some inherent error in the reference oscillator's actual frequency
135135

136136
The calibration method is called like this:
137137

138-
si5351.set_correction(-6190);
138+
si5351.set_correction(-6190, SI5351_PLL_INPUT_XO);
139139

140140
However, you may use the third argument in the _init()_ method to specify the frequency correction and may not actually need to use the explict _set_correction()_ method in your code.
141141

@@ -219,18 +219,25 @@ Using an External Reference (Si5351C)
219219
-------------------------------------
220220
_Please see the example sketch **si5351_ext_ref.ino**_
221221

222-
The Si5351C variant has a CLKIN input (pin 6) which allows the use of an alternate external CMOS clock reference from 10 to 100 MHz. Either PLLA and/or PLLB can be locked to this external reference. The library currently only supports the calculations to use one reference signal, which is declared at initialization:
222+
The Si5351C variant has a CLKIN input (pin 6) which allows the use of an alternate external CMOS clock reference from 10 to 100 MHz. Either PLLA and/or PLLB can be locked to this external reference. The library tracks the referenced frequencies and correction factors individually for both the crystal oscillator reference (XO) and external reference (CLKIN).
223223

224-
// Initialize the Si5351 to use a 10 MHz clock input on CLKIN
225-
si5351.init(SI5351_CRYSTAL_LOAD_0PF, 10000000UL, 0);
224+
The XO reference frequency is set during the call to _init()_. If you are going to use the external reference clock, then set its nominal frequency with the _set_ref_freq()_ method:
225+
226+
// Set the CLKIN reference frequency to 10 MHz
227+
si5351.set_ref_freq(10000000UL, SI5351_PLL_INPUT_CLKIN);
228+
229+
A correction factor for the external reference clock may also now be set:
230+
231+
// Apply a correction factor to CLKIN
232+
si5351.set_correction(0, SI5351_PLL_INPUT_CLKIN);
226233

227234
The _set_pll_input()_ method is used to set the desired PLLs to reference to the external reference signal on CLKIN instead of the XO signal:
228235

229236
// Set PLLA and PLLB to use the signal on CLKIN instead of the XTAL
230237
si5351.set_pll_input(SI5351_PLLA, SI5351_PLL_INPUT_CLKIN);
231238
si5351.set_pll_input(SI5351_PLLB, SI5351_PLL_INPUT_CLKIN);
232239

233-
Once that is set, the library can be used as you normally would, with all of the frequency calculations done based on the reference frequency set in _init()_.
240+
Once that is set, the library can be used as you normally would, with all of the frequency calculations done based on the reference frequency set in _set_ref_freq()_.
234241

235242

236243
Alternate I2C Addresses
@@ -313,7 +320,7 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
313320
* track that all settings are sane yourself.
314321
*
315322
* freq - Output frequency in Hz
316-
* pll_freq - Frequency of the PLL driving the Multisynth
323+
* pll_freq - Frequency of the PLL driving the Multisynth in Hz * 100
317324
* clk - Clock output
318325
* (use the si5351_clock enum)
319326
*/
@@ -325,7 +332,7 @@ uint8_t Si5351::set_freq(uint64_t freq, enum si5351_clock clk)
325332
*
326333
* Set the specified PLL to a specific oscillation frequency
327334
*
328-
* pll_freq - Desired PLL frequency
335+
* pll_freq - Desired PLL frequency in Hz * 100
329336
* target_pll - Which PLL to set
330337
* (use the si5351_pll enum)
331338
*/
@@ -391,7 +398,11 @@ void Si5351::update_status(void)
391398
### set_correction()
392399
```
393400
/*
394-
* set_correction(int32_t corr)
401+
* set_correction(int32_t corr, enum si5351_pll_input ref_osc)
402+
*
403+
* corr - Correction factor in ppb
404+
* ref_osc - Desired reference oscillator
405+
* (use the si5351_pll_input enum)
395406
*
396407
* Use this to set the oscillator correction factor.
397408
* This value is a signed 32-bit integer of the
@@ -412,7 +423,7 @@ void Si5351::update_status(void)
412423
* should not have to be done again for the same Si5351 and
413424
* crystal.
414425
*/
415-
void Si5351::set_correction(int32_t corr)
426+
void Si5351::set_correction(int32_t corr, enum si5351_pll_input ref_osc)
416427
```
417428
### set_phase()
418429
```
@@ -433,12 +444,16 @@ void Si5351::set_phase(enum si5351_clock clk, uint8_t phase)
433444
### get_correction()
434445
```
435446
/*
436-
* get_correction(void)
447+
* get_correction(enum si5351_pll_input ref_osc)
448+
*
449+
* ref_osc - Desired reference oscillator
450+
* 0: crystal oscillator (XO)
451+
* 1: external clock input (CLKIN)
437452
*
438453
* Returns the oscillator correction factor stored
439454
* in RAM.
440455
*/
441-
int32_t Si5351::get_correction(void)
456+
int32_t Si5351::get_correction(enum si5351_pll_input ref_osc)
442457
```
443458
### pll_reset()
444459
```
@@ -570,6 +585,31 @@ void Si5351::set_clock_fanout(enum si5351_clock_fanout fanout, uint8_t enable)
570585
*/
571586
void Si5351::set_pll_input(enum si5351_pll pll, enum si5351_pll_input input)
572587
```
588+
### set_vcxo()
589+
```
590+
/*
591+
* set_vcxo(uint64_t pll_freq, uint8_t ppm)
592+
*
593+
* pll_freq - Desired PLL base frequency in Hz * 100
594+
* ppm - VCXO pull limit in ppm
595+
*
596+
* Set the parameters for the VCXO on the Si5351B.
597+
*/
598+
void Si5351::set_vcxo(uint64_t pll_freq, uint8_t ppm)
599+
```
600+
### set_ref_freq()
601+
```
602+
/*
603+
* set_ref_freq(uint32_t ref_freq, enum si5351_pll_input ref_osc)
604+
*
605+
* ref_freq - Reference oscillator frequency in Hz
606+
* ref_osc - Which reference oscillator frequency to set
607+
* (use the si5351_pll_input enum)
608+
*
609+
* Set the reference frequency value for the desired reference oscillator
610+
*/
611+
void Si5351::set_ref_freq(uint32_t ref_freq, enum si5351_pll_input ref_osc)
612+
```
573613
### si5351_write_bulk()
574614
```
575615
uint8_t Si5351::si5351_write_bulk(uint8_t addr, uint8_t bytes, uint8_t *data)
@@ -666,6 +706,10 @@ This library does not currently support the spread spectrum function of the Si53
666706
Changelog
667707
---------
668708

709+
* v2.1.0
710+
711+
* Add support for reference frequencies and corrections for both the XO and CLKIN
712+
669713
* v2.0.7
670714

671715
* Change _set_freq()_ behavior so that the output is only automatically enabled the very first time that _set_freq()_ is called

examples/si5351_ext_ref/si5351_ext_ref.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ void setup()
2828
// Start serial
2929
Serial.begin(57600);
3030

31-
// Initialize the Si5351 to use a 10 MHz clock input on CLKIN
32-
si5351.init(SI5351_CRYSTAL_LOAD_0PF, 10000000UL, 0);
31+
// Initialize the Si5351 to use a 25 MHz clock on the XO input
32+
si5351.init(SI5351_CRYSTAL_LOAD_0PF, 0, 0);
33+
34+
// Set the CLKIN reference frequency to 10 MHz
35+
si5351.set_ref_freq(10000000UL, SI5351_PLL_INPUT_CLKIN);
36+
37+
// Apply a correction factor to CLKIN
38+
si5351.set_correction(0, SI5351_PLL_INPUT_CLKIN);
3339

3440
// Set PLLA and PLLB to use the signal on CLKIN instead of the XTAL
3541
si5351.set_pll_input(SI5351_PLLA, SI5351_PLL_INPUT_CLKIN);

keywords.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set_clock_disable KEYWORD2
2222
set_clock_fanout KEYWORD2
2323
set_pll_input KEYWORD2
2424
set_vcxo KEYWORD2
25+
set_ref_freq KEYWORD2
2526
si5351_write_bulk KEYWORD2
2627
si5351_write KEYWORD2
2728
si5351_read KEYWORD2
@@ -32,6 +33,8 @@ clk_freq KEYWORD2
3233
plla_freq KEYWORD2
3334
pllb_freq KEYWORD2
3435
xtal_freq KEYWORD2
36+
plla_ref_osc KEYWORD2
37+
pllb_ref_osc KEYWORD2
3538

3639
SI5351_PLL_FIXED LITERAL1
3740
SI5351_FREQ_MULT LITERAL1

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Etherkit Si5351
2-
version=2.0.6
2+
version=2.1.0
33
author=Jason Milldrum <milldrum@gmail.com>
44
maintainer=Jason Milldrum <milldrum@gmail.com>
55
sentence=A full-featured library for the Si5351 series of clock generator ICs from Silicon Labs

0 commit comments

Comments
 (0)