Skip to content

Commit 12b4e00

Browse files
committed
Compiling. TODO: setFrequencyByBiasMillis
1 parent fae5f42 commit 12b4e00

File tree

5 files changed

+396
-151
lines changed

5 files changed

+396
-151
lines changed

.github/workflows/compile-sketch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- source-url: https://github.com/sparkfun/SparkFun_Toolkit.git
104104
# - name: name-of-library-registered-with-arduino-library-manager
105105
sketch-paths: |
106-
- examples/Example05_AlternateAddress
106+
- examples/Example01_AlternateAddress
107107
enable-warnings-report: true
108108
enable-deltas-report: true
109109
verbose: true

examples/Example01_AlternateAddress/Example01_AlternateAddress.ino

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
// You will need the SparkFun Toolkit. Click here to get it: http://librarymanager/All#SparkFun_Toolkit
1515

16-
#include <SparkFun_ADS1219.h> // Click here to get the library: http://librarymanager/All#SparkFun_ADS1219
16+
#include <SparkFun_SiT5358.h> // Click here to get the library: http://librarymanager/All#SparkFun_SiT5358
1717

18-
SfeADS1219ArdI2C myADC;
18+
SfeSiT5358ArdI2C myTCXO;
1919

2020
void setup()
2121
{
@@ -26,34 +26,33 @@ void setup()
2626
{
2727
delay(100); // Wait for the user to open the Serial Monitor
2828
}
29-
Serial.println("SparkFun ADS1219 Example");
29+
Serial.println("SparkFun SiT5358 Example");
3030

3131
Wire.begin(); // Begin the I2C bus
3232

3333
bool begun;
34-
begun = myADC.begin(Wire, 0x4F); // Initialize the ADC - using a custom bus and address - see notes above
35-
begun = myADC.begin(0x4F); // This is also possible. It defaults to Wire
34+
begun = myTCXO.begin(Wire, 0x60); // Initialize the SiT5358 - using a custom bus and address
35+
begun = myTCXO.begin(0x60); // This is also possible. It defaults to Wire
36+
begun = myTCXO.begin(); // This is also possible. It defaults to Wire and address 0x60
3637

3738
if (!begun)
3839
{
39-
Serial.println("ADC not detected! Please check the address and try again...");
40+
Serial.println("SiT5358 not detected! Please check the address and try again...");
4041
while (1); // Do nothing more
4142
}
4243

43-
Serial.println("Reading the differential voltage between AIN0 (+) and AIN1 (-)");
44+
// Read the frequency control word - should be zero initially
45+
int32_t fcw = myTCXO.getFrequencyControlWord();
46+
Serial.print("The frequency control word is: ");
47+
Serial.println(fcw);
48+
49+
// Read the pull range control
50+
uint8_t prc = myTCXO.getPullRangeControl();
51+
Serial.print("Pull range control is: ");
52+
Serial.println(myTCXO.getPullRangeControlText(prc));
4453
}
4554

4655
void loop()
4756
{
48-
myADC.startSync(); // Start a single-shot conversion.
49-
50-
while (myADC.dataReady() == false) // Check if the conversion is complete. This will return true if data is ready.
51-
{
52-
delay(10); // The conversion is not complete. Wait a little to avoid pounding the I2C bus.
53-
}
54-
55-
myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.
56-
int32_t sample = myADC.getConversionRaw(); // Get the raw ADC value. Note: this is NOT adjusted for gain.
57-
Serial.print("Raw ADC value: ");
58-
Serial.println(sample); // Print the raw ADC value
57+
// Nothing to do here
5958
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Set the frequency of the SiT5358 DCTCXO.
3+
4+
By: Paul Clark
5+
SparkFun Electronics
6+
Date: 2024/8/1
7+
SparkFun code, firmware, and software is released under the MIT License.
8+
Please see LICENSE.md for further details.
9+
10+
*/
11+
12+
// You will need the SparkFun Toolkit. Click here to get it: http://librarymanager/All#SparkFun_Toolkit
13+
14+
#include <SparkFun_SiT5358.h> // Click here to get the library: http://librarymanager/All#SparkFun_SiT5358
15+
16+
SfeSiT5358ArdI2C myTCXO;
17+
18+
void setup()
19+
{
20+
delay(1000); // Allow time for the microcontroller to start up
21+
22+
Serial.begin(115200); // Begin the Serial console
23+
while (!Serial)
24+
{
25+
delay(100); // Wait for the user to open the Serial Monitor
26+
}
27+
Serial.println("SparkFun SiT5358 Example");
28+
29+
Wire.begin(); // Begin the I2C bus
30+
31+
if (!myTCXO.begin())
32+
{
33+
Serial.println("SiT5358 not detected! Please check the address and try again...");
34+
while (1); // Do nothing more
35+
}
36+
37+
myTCXO.setBaseFrequencyHz(10000000.0); // Pass the oscillator base frequency into the driver
38+
39+
Serial.print("Base frequency set to ");
40+
Serial.println(myTCXO.getBaseFrequencyHz());
41+
Serial.println(" Hz");
42+
43+
myTCXO.setPullRangeControl(SiT5358_PULL_RANGE_200ppm); // Set the pull range control to 200ppm
44+
45+
Serial.print("Pull range control set to ");
46+
Serial.println(myTCXO.getPullRangeControlText(myTCXO.getPullRangeControl()));
47+
48+
myTCXO.setFrequencyHz(10001000.0); // Set the frequency to 10.001MHz (+100ppm)
49+
50+
Serial.print("Frequency set to ");
51+
Serial.print(myTCXO.getFrequencyHz());
52+
Serial.println(" Hz");
53+
54+
Serial.print("Frequency control word should be 16777216. It is ");
55+
Serial.println(myTCXO.getFrequencyControlWord());
56+
}
57+
58+
void loop()
59+
{
60+
// Nothing to do here
61+
}

0 commit comments

Comments
 (0)