Skip to content

Commit

Permalink
Correct write to register 183 to pre-load correct value
Browse files Browse the repository at this point in the history
  • Loading branch information
NT7S committed Mar 20, 2016
1 parent 24957cb commit b3124ab
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
9 changes: 7 additions & 2 deletions README.md
Expand Up @@ -472,6 +472,7 @@ Here are the defines, structs, and enumerations you will find handy to use with

Crystal load capacitance:

SI5351_CRYSTAL_LOAD_0PF
SI5351_CRYSTAL_LOAD_6PF
SI5351_CRYSTAL_LOAD_8PF
SI5351_CRYSTAL_LOAD_10PF
Expand Down Expand Up @@ -500,7 +501,7 @@ Clock disable states:
Clock fanout:

enum si5351_clock_fanout {SI5351_FANOUT_CLKIN, SI5351_FANOUT_XO, SI5351_FANOUT_MS};

PLL input sources:

enum si5351_pll_input{SI5351_PLL_INPUT_XO, SI5351_PLL_INPUT_CLKIN};
Expand Down Expand Up @@ -541,10 +542,14 @@ Right now, this code is focused solely on the 3-output 10-MSOP variant (Si5351A3

Changelog
---------
* v1.1.2

Fix error where register 183 is not pre-loaded with correct value per AN619. Add define for SI5351_CRYSTAL_LOAD_0PF (undocumented in AN619 but present in the official ClockBuilder software).

* v1.1.1

Fix if statement eval error in set_clock_disable()

* v1.1.0

Added set_pll_input() method to allow toggling the PLL reference source for the Si5351C variant and added support to init() for different PLL reference frequencies from 10 to 100 MHz.
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Expand Up @@ -34,6 +34,7 @@ clk1_int_mode KEYWORD2
clk2_int_mode KEYWORD2

SI5351_PLL_FIXED LITERAL1
SI5351_CRYSTAL_LOAD_0PF LITERAL1
SI5351_CRYSTAL_LOAD_6PF LITERAL1
SI5351_CRYSTAL_LOAD_8PF LITERAL1
SI5351_CRYSTAL_LOAD_10PF LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.properties
@@ -1,5 +1,5 @@
name=Etherkit Si5351
version=1.1.1
version=1.1.2
author=Jason Milldrum <milldrum@gmail.com>
maintainer=Jason Milldrum <milldrum@gmail.com>
sentence=A full-featured library for the Si5351 series of clock generator ICs from Silicon Labs
Expand Down
8 changes: 5 additions & 3 deletions src/si5351.cpp
@@ -1,8 +1,8 @@
/*
* si5351.cpp - Si5351 library for Arduino
*
* Copyright (C) 2015 Jason Milldrum <milldrum@gmail.com>
* Dana H. Myers <k6jq@comcast.net>
* Copyright (C) 2015-2016 Jason Milldrum <milldrum@gmail.com>
* Dana H. Myers <k6jq@comcast.net>
*
* Some tuning algorithms derived from clk-si5351.c in the Linux kernel.
* Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Expand Down Expand Up @@ -66,7 +66,9 @@ void Si5351::init(uint8_t xtal_load_c, uint32_t ref_osc_freq)
Wire.begin();

// Set crystal load capacitance
si5351_write(SI5351_CRYSTAL_LOAD, xtal_load_c);
uint8_t reg_val = 0x12; // 0b010010 reserved value bits
reg_val |= xtal_load_c;
si5351_write(SI5351_CRYSTAL_LOAD, reg_val);

// Change the ref osc freq if different from default
// Divide down if greater than 30 MHz
Expand Down
5 changes: 3 additions & 2 deletions src/si5351.h
@@ -1,8 +1,8 @@
/*
* si5351.h - Si5351 library for Arduino
*
* Copyright (C) 2015 Jason Milldrum <milldrum@gmail.com>
* Dana H. Myers <k6jq@comcast.net>
* Copyright (C) 2015-2016 Jason Milldrum <milldrum@gmail.com>
* Dana H. Myers <k6jq@comcast.net>
*
* Many defines derived from clk-si5351.h in the Linux kernel.
* Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Expand Down Expand Up @@ -171,6 +171,7 @@

#define SI5351_CRYSTAL_LOAD 183
#define SI5351_CRYSTAL_LOAD_MASK (3<<6)
#define SI5351_CRYSTAL_LOAD_0PF (0<<6)
#define SI5351_CRYSTAL_LOAD_6PF (1<<6)
#define SI5351_CRYSTAL_LOAD_8PF (2<<6)
#define SI5351_CRYSTAL_LOAD_10PF (3<<6)
Expand Down

0 comments on commit b3124ab

Please sign in to comment.