25 Mhz Init not working
AtariAndre opened this issue · 4 comments
Hi Pavel,
I found this library and it seems just what I need. I am using a "China" Attinny85 board with an original Adafruit SI5351 breakout board.
I tried a simple program to run 1 clock (0) at 16 Mhz. However when I measure I get an output of 14.8 Mhz instead. I think the Si.init(25000000); command seems to be ignored somehow (The Adafruit uses a 25Mhz crystal.
When I use Si.init(); I get also 14.8 Mhz on the output.
Am I doing something wrong ?
Thanks !
here is the code, basically your demo with added in some (stupid) fixed texts to a OLED display.
/*
- si5351mcu - Si5351 library for Arduino, MCU tuned for size and click-less
- This is the packed simplest example.
- Copyright (C) 2017 Pavel Milanes pavelmc@gmail.com
- Many chunk of codes are derived-from/copied from other libs
- all GNU GPL licenced:
-
- Linux Kernel (www.kernel.org)
-
- Hans Summers libs and demo code (qrp-labs.com)
-
- Etherkit (NT7S) Si5351 libs on github
-
- DK7IH example.
-
- Jerry Gaffke integer routines for the bitx20 group
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see http://www.gnu.org/licenses/.
*/
/***************************************************************************
- Just put two frequencies out in clk0 and clk1 at different power levels
- Take into account your XTAL error, see Si.correction(###) below
***************************************************************************/
#include <DigisparkOLED.h>
#include "si5351mcu.h"
// lib instantiation as "Si"
Si5351mcu Si;
// some variables
long F1 = 16000000; // 16.0 MHz to CLK0
void setup() {
// init the Si5351 lib
Si.init(25000000);
// For a different xtal (from the default of 27.00000 Mhz)
// just pass it on the init procedure, just like this
// Si.init(26570000);
// set & apply my calculated correction factor
// Si.correction(-1250);
// set max power to both outputs
Si.setPower(0, SIOUT_8mA);
// Set frequencies
Si.setFreq(0, F1);
// reset the PLLs
Si.reset();
oled.begin();
oled.setFont(FONT8X16);
//oled.println(millis());"
}
byte bCursor = 0x20;
// the loop routine runs over and over again forever:
void loop() {
oled.setCursor(0, 0); //top left
oled.print(F("Lynx Turbo Boost"));
oled.write(10); // write NewLine [save 30 bytes over println]
oled.write(10); // write NewLine [save 30 bytes over println]
oled.print(F("Frequency 16 Mhz"));
delay(1000); // keep usb alive // can also use SerialUSB.refresh();
oled.write(bCursor = ~bCursor); // Toggle 'SPACE' with some whitish char 223
// do nothing
}
I have now fixed this by changing the value of 27000000 to 25000000 in the library. Now I do get 16 Mhz output. Sometimes the Si5351 doesn't seem to initialize correctly after first upload of the Sketch. power off- on helps.
Mmmm, very strange......very often I now get 25 Mhz instead of 16 Mhz after powering off/on.
weird.
Hi Atari Andre, I will check with the hardware at home, but at leas with a Arduino Pro-mini it worked fine 100% of the time... Maybe it's a platform specific condition of the Attinny85 ?
A catch 22 tip: when you power cycle the arduino Attinny85 board the +3.3 voltage in the Si5351 board do get power cycled also?
If not, you are facing a re-initialization problem, a user with a custom board confronted a problem like that a time ago (here in my town) he put a 1000uF cap in the +3.3v and a reset of a fast power cycle does not give time for the +3.3v line to really drop and that cause troubles, a 47uF do the trick for him.
Cheers.