10 MHz Ref Input

I have the 10 MHz reference input working on my LimeSDR. I was able to use LimeSuite to set it up. Once set, I could close LimeSuite and open SDRConsole and that appears to work fine.

10 MHz is connected to J14 - Ref Clock Input. MAKE SURE TO NOT OVERDRIVE IT! (ADF4002) Spec sheet shows -10 to 0 dBm Max.

There are 4 LED’s on the board. Three are usually functional. The fourth LED is the 10 MHz Lock LED.

Power up the board without the 10 MHz connected. Open LimeSuite and connect to the board. Then, under ‘Modules’ open ADF4002. Make sure the Fref and Fvco look like this, then press Calculate R, N & Upload.

The fourth LED on the board should turn red. Plug in the 10 MHz ref and it will turn green.

Quit LimeSuite and open SDRConsole and away you go.

Mike, N1JEZ


Tnx N1JEZ. I tried to connect my 10Mhz gpsdo as ref clock input of limesdr as he described, it really works. But I find that the configuration will lost when I power off the limesdr board. So how can I store the configuration permanently?

I dont think you can save it memory but you can save the “INI” so that you can load it back on again

Tnx for the answer. The osmocom source in Gnuradio Companion has an option to select the colock source, but it has not any effect when I select “External” clock source. Any thing wrong?


can some one please point me to the API in LimeSuite to switch 10 MHz input programmatically?

Thank you and best regards,

Edit: I saw this in LimeSuite.h


  • Set frequency of the specified clock
  • @note setting ::LMS_CLOCK_EXTREF changes clock source to external, use
  • ::LMS_VCTCXOWrite() to change back to VCTCXO
  • @param dev Device handle previously obtained by LMS_Open().
  • @param clk_id Clock identifier
  • @param freq Clock frequency in Hz. Pass zero or negative value to only
  •              perform tune (if supported) without recalculating values
  • @return 0 on success, (-1) on failure
    API_EXPORT int CALL_CONV LMS_SetClockFreq(lms_device_t *dev, size_t clk_id,
    float_type freq);

Does this mean that the clock frequency (ex: 10 MHz) should be specified?

This is an excerpt from a paper I wrote. It shows where to set up 10 MHz in LimeSuiteGUI.

It is possible to lock the LimeSDR to a 10 MHz reference for frequency stability.
Connect to your board with LimeSuiteGUI and then select Modules | ADF4002 from the
menu bar. You will see this screen.

On the upper right, Fref, MHz is 10. Press Calculate R, N & Upload. On the board, there
is a fourth LED that is usually extinguished. It will be red if you have no reference input
and will be green if the signal is present and good. The Reference Input U.FL connector
is near the LEDs on the board.
Make sure to not overdrive the Reference input! The ADF4002 spec calls for a level
between 0 and -10 dBm.

I was meaning by a call to the API from a program but I think LMS_SetClockFreq is the answer. Here: http://docs.myriadrf.org/LMS_API/group___f_n___l_o_w___l_v_l.html#gaf654ad677321956d6d782a9003d939c4 it says “setting LMS_CLOCK_EXTREF changes clock source to external, use LMS_VCTCXOWrite() to change back to VCTCXO”

1 Like


another question about the LMS API LMS_SetClockFreq: in this function you can specify a frequency along with the LMS_CLOCK_EXTREF as clock id. Does this mean that the external clock frequency can be different than 10 MHz? Can this API be used to make LimeSDR work with an external clock different than 10 MHz?

Best regards, Edouard.

Edit: in another post it states that in fact this is the input to a ADF4002 IC: http://www.analog.com/media/en/technical-documentation/data-sheets/ADF4002.pdf While REFCLK range is 20 to 300 MHz it says the frequency can be lower provided the slew rate should be larger than 50 V/µs. Then what is the actual lower limit?

Hi Edouard,

Just updated my firmware to 17.10 and ran the latest SDRangle version to check the 10 MHz Ref lock. It is working as expected! Great job - Tnx!


Does someone have the switch to ext ref in a short bit of code that can be compiled and called from a command line before starting up our main application?

Just got an ebay special Trimble GPSTM connected thru a 10db attenuator and the green light came on as expected.

1 Like

Here’s code to do it - just grabbed someone else’s source (mylime.cpp) and deleted a bunch of stuff and copied the above in :slight_smile:


compile with:
$ g++ -o extREF extREF.cpp -std=c++11 -lLimeSuite

$ sudo ./extREF
Devices found: 1
Reference clock 30.72 MHz

And the green light comes on.
There’s a note in there about init:
//Initialize device with default configuration
//Do not use if you want to keep existing configuration
if (LMS_Init(m_lms_device) != 0) error();
//if (LMS_Reset(m_lms_device) != 0) error();


@F4EXB, @ba5ham, @cswiger, thanks for the above lead. I took a look at the LimeSuiteGUI code to figure out how to set the reference clock frequency. It turns out that this involves SPI writes to the ADF4002 phase modulator chip. I extended your code a bit to perform the update from a command line. This code should be extended to allow a user to specify F(ref) as a command-line parameter - set the external clock frequency by assigning a float value (in megahertz) to fref in main():

#include <cstdlib>
#include "lime/lms7_device.h"
#include "lime/LimeSuite.h"
#include "lime/ADF4002.h"
#include <iostream>
#include "math.h"
#include <thread>
#include <memory.h>
using namespace std;
using namespace lime;

#define N_RADIOS 1

static lime::ADF4002 *adf4002;
static float_type fref, fvco;
static lms_device_t* m_lms_device;
static int m_n_devices;

static int error()
    //print last error message
    cout << "ERROR:" << LMS_GetLastErrorMessage();
    if (m_lms_device != NULL)

int main( void )
    fref = 10.0;
    fvco = 30.72;
    unsigned char adf4002_spi[12];

    int rCount, nCounter;
    int result;

    lms_info_str_t list[N_RADIOS]; //should be large enough to hold all detected devices

    memset(&adf4002_spi, 0, 12);

    try {
      adf4002 = nullptr;
      adf4002 = new lime::ADF4002();
    } catch (...) {
      adf4002 = nullptr;

    if ( adf4002 == nullptr ) {
      cerr << "Unable to set up ADF4002 data structs." << endl;
      return -1;

    cout << "Setting ADF4002 defaults" << endl;

    m_lms_device = NULL;

    if ((m_n_devices = LMS_GetDeviceList(list)) < 0) error();//NULL can be passed to only get number of devices

    cout << "Devices found: " << m_n_devices << endl; //print number of devices

    if (m_n_devices < 1) {
      cout << "No device found" << endl;
      return -1;

    //open the first device
    if (LMS_Open(&m_lms_device, list[0], NULL)) {
      if ( m_lms_device != NULL )
      cout << "Unable to open zeroth device" << endl;
      return -1;

    cout << "Device opened. Initializing..." << endl;

    //Initialize device with default configuration
    if (LMS_Init(m_lms_device) != 0) {
      cout << "Unable to initialize device" << endl;
      return -2;

    if (1 == LMS_IsOpen(m_lms_device,0)) {

      adf4002->SetFrefFvco(fref, fvco, rCount, nCounter);

      vector<uint32_t> bytearray;

      for ( int n = 0; n < 12 ; n+= 3 )
        bytearray.push_back((uint32_t)adf4002_spi[n] << 16 |
            (uint32_t)adf4002_spi[n+1] << 8 |

      cout << "Setting ( Fref, Fvco ) to ( " << fref << ", " << fvco << " )" << endl;

      auto conn = ((LMS7_Device *)m_lms_device)->GetConnection();

      result = conn->TransactSPI(conn->GetDeviceInfo().addrADF4002,
          4 );

      if ( result != 0 )
        cout << "Unable to set external clock frequency" << endl;
        cout << "Fref set" << endl;


    if ( !(adf4002 == nullptr) ) {
      delete adf4002;
      adf4002 = nullptr;

    return 0;

I’m using the Leo Bodnar mini GPSDO reference clock, preconfigured to generate 10MHz. After running this tool, with the clock source attached to REF IN, I see the (PLL lock indicator?) LED lamp turn green. Setting a different frequency either in the tool, or generated by the GPSDO, causes the LED to turn red.

See src/ADF4002/ADF4002_wxgui.cpp (function void ADF4002_wxgui::OnbtnCalcSendClick(wxCommandEvent& event) ) and src/ADF4002/ADF4002.cpp, from the LimeSuite Git source tree.

Edit: A small caveat - the code above only compiles without error with LimeSuite tag v17.10. You will need to modify the TransactSPI call to use a suitable first parameter, as “addrADF4002” is undefined as used here, in branch 18.0.4.

1 Like

@avahilario - I also have Leo Bodnar’s mini GPSDO, just wondering if you are connecting it via attenuator to the REF IN and which power level are you using in GPSDO (8ma, 16ma, 24ma, or 32ma)?


Hi @sharp1e - I’d selected the lowest drive setting (8ma), no attenuator. This is almost certainly a bad idea - although the ADF4002 REF IN input is specced for CMOS voltage levels, the 3V output of the GPSDO is very close to the maximum input rating (Vdd + 0.3v). Noticing that the schematic at page 14 shows two 1nF decoupling capacitors at the REF IN pin of the phase detector, I figured I’d experiment before buying a 10dB attenuator.

It’s worked so far. Both the LimeSDR and GPSDO are connected to a USB 3 hub, and so share a common ground. However, a stray discharge that comes in through the GPS antenna will almost certainly use both paths (Lime and GPSDO) to ground, some of that energy maybe killing the phase detector.

We should probably be using at least a 10dB attenuator; both Leo Bodnar GPSDO models output +7.7dBm at the 8ma drive setting @10MHz.

@avahilario – thanks for this info! For some reason LimeSDR is not locking on 10Mhz on my side. When I click “Calculate N, R & Upload” Red light LED (for ref clock) extinguishes but never changes to green. GPSDO is locked on sats (steady red light on it) and outputs 10Mhz. I tried 8ma with and without 10db attenuator – same effect.

I haven’t had this happen - with the GPSDO attached to REF In via SMA patch cable (and getting power via the same USB hub as the LimeSDR 1.4); GPSDO tuned to 10MHz, with sat acquisition done and PLL lock; and using LimeSuiteGUI to set Fref to 10MHz, I get the PLL lock LED turn green. Tuning the GPSDO a few hundred hertz up or down causes the LED to turn red.

The external reference PLL lock LED is off on board powerup, even with the GPSDO attached, and only toggles on after I use either LimeSuiteGUI or @cswiger 's script to switch to the external clock.

We need help diagnosing this; perhaps @Zack or @cswiger have seen this happen before.

You might double-check the seating of the REF In clock uFL connector, and that the SMA bulkhead connectors are screwed on hand-tight. Also, try and see whether you can tune the SDR with some app. I use GQRX for this, to pick up local radio on LNAW, and wifi, cellular bands on LNAH / LNAL.

The PLL lock going off after clicking on “Calculate R, N & Upload” doesn’t seem a good sign. Except for the power LED, the other three LEDs are controlled by the FPGA; so it’s likely “a thing” with the gateware + LimeSuiteGUI software rather than damage to the AD4002.

Hi @5harp1e,

Could you paste a print screen of ADF4002 module dialog window, please.

Hey guys, I checked physical connections SMA uFL to the board socket – everything looks good and tight. I was suspicious of connection issue initially but the fact that REF clock LED goes from RED to off only when I supply GPSDO signal tells me that it senses something and cable/connectors are not likely it. I.e. when I disconnect GPSDO from the REF IN SMA connector the LED goes back from OFF to RED. That’s all happening after I opened ADF4002 module and clicked on “Calculate R,N & Upload” of course. See attached picture of what I have there before I click on it.

When I change Calculation of R N Fref, Mhz up or down from 10Mhz when feeding 10Mhz from GPSDO that light goes from OFF back to RED, which is indicative it sees a freq mismatch, once I am back to 10Mhz it goes off again. Never turns green, but I know this is a bi-color LED and it is capable of shining green. :slight_smile:

This is GW version I am running:
[17:46:17] INFO: Disconnected control port
[17:46:25] INFO: Reference clock 30.72 MHz
[17:46:25] INFO: Connected Control port: LimeSDR-USB FW:4 HW:4 Protocol:1 GW:2.16 Ref Clk: 30.72 MHz

LimeSDR Board v. 1.4

The board works fine in all other respects – GQRX (all bands), Osomo-GSM stack Voice, SMS, GPRS, and lots of other projects. It’s just doing it with internal 30.72Mhz clock. I wanted to use Ext GPSDO because after running GSM stack for some time ambient temp goes up (no fan, just radiators for now) and I think this extra heat causing internal clock drift and osmo-trx looses timing. Sorry, that’s a different subject.

…and this is LimeSuite version info
Screenshot from 2018-06-28 18-25-26