FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

manual merge · etherkit/Si5351Arduino@ad6005a · GitHub

Repository navigation

Commit ad6005a

Browse files
committed
manual merge
2 parents 5726a58 + 273e9fa commit ad6005a

13 files changed

Lines changed: 1607 additions & 583 deletions

File tree

‎README.md‎

Lines changed: 204 additions & 86 deletions
Large diffs are not rendered by default.

examples/si5351calibration/si5351calibration.ino renamed to examples/si5351_calibration/si5351_calibration.ino

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
/* Simple calibration routine for the Si5351 breakout board.
1+
/*
2+
* si5351_calibration.ino - Simple calibration routine for the Si5351
3+
* breakout board.
24
*
3-
* Copyright 2015 Paul Warren <pwarren@pwarren.id.au>
5+
* Copyright 2015 - 2016 Paul Warren <pwarren@pwarren.id.au>
6+
* Jason Milldrum <milldrum@gmail.com>
47
*
58
* Uses code from https://github.com/darksidelemm/open_radio_miniconf_2015
69
* and the old version of the calibration sketch
@@ -22,7 +25,7 @@
2225

2326
Si5351 si5351;
2427

25-
int32_t cal_factor;
28+
int32_t cal_factor = 0;
2629
int32_t old_cal;
2730

2831
uint64_t rx_freq;
@@ -32,40 +35,38 @@ void setup()
3235
{
3336
// Start serial and initialize the Si5351
3437
Serial.begin(57600);
35-
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
3638

37-
// get old cal factor
38-
//old_cal = si5351.get_correction();
39-
si5351.set_correction(0);
40-
// start on target frequency
41-
si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
42-
si5351.set_freq(target_freq, SI5351_PLL_FIXED, SI5351_CLK0);
39+
// The crystal load value needs to match in order to have an accurate calibration
40+
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
41+
42+
// Start on target frequency
43+
si5351.set_freq(target_freq, SI5351_CLK0);
4344
}
4445

4546
void loop()
4647
{
4748
si5351.update_status();
48-
if (si5351.dev_status.SYS_INIT == 1) {
49-
Serial.println("Initialising Si5351, you shouldn't see many of these!");
49+
if (si5351.dev_status.SYS_INIT == 1)
50+
{
51+
Serial.println(F("Initialising Si5351, you shouldn't see many of these!"));
5052
delay(500);
51-
} else {
52-
cal_factor = 0;
53-
// Serial.print("Old cal factor was: ");
54-
// Serial.println(old_cal);
55-
// Serial.println("Cal factor now set to 0");
56-
// si5351.set_correction(0);
53+
}
54+
else
55+
{
5756
Serial.println();
58-
Serial.println(F("Adjust until your frequency counter reads as close to 10 MHz as possible"));
57+
Serial.println(F("Adjust until your frequency counter reads as close to 10 MHz as possible."));
58+
Serial.println(F("Press 'q' when complete."));
5959
vfo_interface();
60+
61+
Serial.println();
6062
Serial.print(F("Calibration factor is "));
6163
Serial.println(cal_factor);
62-
Serial.println("Setting calibration factor");
64+
Serial.println(F("Setting calibration factor"));
6365
si5351.set_correction(cal_factor);
64-
Serial.println("Resetting target frequency");
65-
si5351.set_freq(target_freq, SI5351_PLL_FIXED, SI5351_CLK0);
66-
}
67-
68-
66+
Serial.println(F("Resetting target frequency"));
67+
si5351.set_freq(target_freq, SI5351_CLK0);
68+
si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
69+
}
6970
}
7071

7172
static void flush_input(void)
@@ -80,10 +81,13 @@ static void vfo_interface(void)
8081
Serial.println(F(" Up: r t y u i o p"));
8182
Serial.println(F(" Down: f g h j k l ;"));
8283
Serial.println(F(" Hz: 0.01 0.1 1 10 100 1K 10k"));
83-
while (1) {
84-
if (Serial.available() > 0) {
84+
while (1)
85+
{
86+
if (Serial.available() > 0)
87+
{
8588
char c = Serial.read();
86-
switch (c) {
89+
switch (c)
90+
{
8791
case 'q':
8892
flush_input();
8993
return;
@@ -105,11 +109,12 @@ static void vfo_interface(void)
105109
// Do nothing
106110
continue;
107111
}
108-
si5351.set_freq(rx_freq,SI5351_PLL_FIXED,SI5351_CLK0);
112+
109113
cal_factor = (int32_t)(target_freq - rx_freq);
110-
Serial.print("Current difference:");
114+
si5351.set_correction(cal_factor);
115+
si5351.set_freq(target_freq, SI5351_CLK0);
116+
Serial.print(F("Current difference:"));
111117
Serial.println(cal_factor);
112118
}
113119
}
114120
}
115-
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* si5351_clk67_example.ino - Simple example of setting CLK6 and CLK7
3+
* outputs using Si5351Arduino library
4+
*
5+
* Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "si5351.h"
22+
#include "Wire.h"
23+
24+
Si5351 si5351;
25+
26+
void setup()
27+
{
28+
// Start serial and initialize the Si5351
29+
Serial.begin(57600);
30+
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
31+
32+
// Set CLK0 to output 14 MHz
33+
si5351.set_freq(1400000000ULL, SI5351_CLK0);
34+
35+
// Set CLK6 to 23 MHz, library sets PLL to 874 MHz
36+
si5351.set_freq(2300000000ULL, SI5351_CLK6);
37+
38+
// This won't work since it is not an even multiple of the PLL (874 MHz)
39+
si5351.set_freq(1234567800ULL, SI5351_CLK7);
40+
41+
// Setting CLK7 to 87.4 MHz will work
42+
si5351.set_freq(8740000000ULL, SI5351_CLK7);
43+
44+
si5351.update_status();
45+
delay(500);
46+
}
47+
48+
void loop()
49+
{
50+
// Read the Status Register and print it every 10 seconds
51+
si5351.update_status();
52+
Serial.print("PLLA: ");
53+
Serial.print((uint32_t)(si5351.plla_freq/100));
54+
Serial.print(" PLLB: ");
55+
Serial.print((uint32_t)(si5351.pllb_freq/100));
56+
Serial.print(" SYS_INIT: ");
57+
Serial.print(si5351.dev_status.SYS_INIT);
58+
Serial.print(" LOL_A: ");
59+
Serial.print(si5351.dev_status.LOL_A);
60+
Serial.print(" LOL_B: ");
61+
Serial.print(si5351.dev_status.LOL_B);
62+
Serial.print(" LOS: ");
63+
Serial.print(si5351.dev_status.LOS);
64+
Serial.print(" REVID: ");
65+
Serial.println(si5351.dev_status.REVID);
66+
67+
delay(10000);
68+
}

examples/si5351example/si5351example.ino renamed to examples/si5351_example/si5351_example.ino

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* si5351example.ino - Simple example of using Si5351Arduino library
2+
* si5351_example.ino - Simple example of using Si5351Arduino library
33
*
4-
* Copyright (C) 2015 Jason Milldrum <milldrum@gmail.com>
4+
* Copyright (C) 2015 - 2016 Jason Milldrum <milldrum@gmail.com>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -16,7 +16,6 @@
1616
* You should have received a copy of the GNU General Public License
1717
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19-
2019

2120
#include "si5351.h"
2221
#include "Wire.h"
@@ -27,14 +26,19 @@ void setup()
2726
{
2827
// Start serial and initialize the Si5351
2928
Serial.begin(57600);
30-
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
29+
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
3130

32-
// Set CLK0 to output 14 MHz with a fixed PLL frequency
33-
si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
34-
si5351.set_freq(1400000000ULL, SI5351_PLL_FIXED, SI5351_CLK0);
31+
// Set CLK0 to output 14 MHz
32+
si5351.set_freq(1400000000ULL, SI5351_CLK0);
3533

36-
// Set CLK1 to output 20 MHz
37-
si5351.set_freq(2000000000ULL, 0ULL, SI5351_CLK1);
34+
// Set CLK1 to output 175 MHz
35+
si5351.set_ms_source(SI5351_CLK1, SI5351_PLLB);
36+
si5351.set_freq_manual(17500000000ULL, 70000000000ULL, SI5351_CLK1);
37+
38+
// Query a status update and wait a bit to let the Si5351 populate the
39+
// status flags correctly.
40+
si5351.update_status();
41+
delay(500);
3842
}
3943

4044
void loop()
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* si5351_ext_ref.ino - Simple example of using an external reference
3+
* clock with the Si5351Arduino library
4+
*
5+
* Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "si5351.h"
22+
#include "Wire.h"
23+
24+
Si5351 si5351;
25+
26+
void setup()
27+
{
28+
// Start serial
29+
Serial.begin(57600);
30+
31+
// Initialize the Si5351 to use a 10 MHz clock input on CLKIN
32+
si5351.init(SI5351_CRYSTAL_LOAD_0PF, 10000000UL, 0);
33+
34+
// Set PLLA and PLLB to use the signal on CLKIN instead of the XTAL
35+
si5351.set_pll_input(SI5351_PLLA, SI5351_PLL_INPUT_CLKIN);
36+
si5351.set_pll_input(SI5351_PLLB, SI5351_PLL_INPUT_CLKIN);
37+
38+
// Set CLK0 to output 14 MHz
39+
si5351.set_freq(1400000000ULL, SI5351_CLK0);
40+
41+
si5351.update_status();
42+
delay(500);
43+
}
44+
45+
void loop()
46+
{
47+
// Read the Status Register and print it every 10 seconds
48+
si5351.update_status();
49+
Serial.print(" SYS_INIT: ");
50+
Serial.print(si5351.dev_status.SYS_INIT);
51+
Serial.print(" LOL_A: ");
52+
Serial.print(si5351.dev_status.LOL_A);
53+
Serial.print(" LOL_B: ");
54+
Serial.print(si5351.dev_status.LOL_B);
55+
Serial.print(" LOS: ");
56+
Serial.print(si5351.dev_status.LOS);
57+
Serial.print(" REVID: ");
58+
Serial.println(si5351.dev_status.REVID);
59+
60+
delay(10000);
61+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* si5351_outputs.ino - How to set different output sources
3+
* with the Si5351Arduino library
4+
*
5+
* Copyright (C) 2016 Jason Milldrum <milldrum@gmail.com>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
#include "si5351.h"
22+
#include "Wire.h"
23+
24+
Si5351 si5351;
25+
26+
void setup()
27+
{
28+
// Start serial and initialize the Si5351
29+
Serial.begin(57600);
30+
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0);
31+
32+
// Set CLK0 to output 14 MHz
33+
si5351.set_freq(1400000000ULL, SI5351_CLK0);
34+
35+
// Enable clock fanout for the XO
36+
si5351.set_clock_fanout(SI5351_FANOUT_XO, 1);
37+
38+
// Enable clock fanout for MS
39+
si5351.set_clock_fanout(SI5351_FANOUT_MS, 1);
40+
41+
// Set CLK1 to output the XO signal
42+
si5351.set_clock_source(SI5351_CLK1, SI5351_CLK_SRC_XTAL);
43+
si5351.output_enable(SI5351_CLK1, 1);
44+
45+
// Set CLK2 to mirror the MS0 (CLK0) output
46+
si5351.set_clock_source(SI5351_CLK2, SI5351_CLK_SRC_MS0);
47+
si5351.output_enable(SI5351_CLK2, 1);
48+
49+
// Change CLK0 output to 10 MHz, observe how CLK2 also changes
50+
si5351.set_freq(1000000000ULL, SI5351_CLK0);
51+
52+
si5351.update_status();
53+
delay(500);
54+
}
55+
56+
void loop()
57+
{
58+
// Read the Status Register and print it every 10 seconds
59+
si5351.update_status();
60+
Serial.print(" SYS_INIT: ");
61+
Serial.print(si5351.dev_status.SYS_INIT);
62+
Serial.print(" LOL_A: ");
63+
Serial.print(si5351.dev_status.LOL_A);
64+
Serial.print(" LOL_B: ");
65+
Serial.print(si5351.dev_status.LOL_B);
66+
Serial.print(" LOS: ");
67+
Serial.print(si5351.dev_status.LOS);
68+
Serial.print(" REVID: ");
69+
Serial.println(si5351.dev_status.REVID);
70+
71+
delay(10000);
72+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL