LTC6946 - Ultralow Noise and Spurious 0.37GHz to 5.7GHz Integer-N Synthesizer with Integrated VCO

Features

  • Low Noise Integer-N PLL with Integrated VCO
  • –226dBc/Hz Normalized In-Band Phase Noise Floor
  • –274dBc/Hz Normalized In-Band 1/f Noise
  • –157dBc/Hz Wideband Output Phase Noise Floor
  • Excellent Spurious Performance
  • Output Divider (1 to 6, 50% Duty Cycle)
  • Output Buffer Muting
  • Low Noise Reference Buffer
  • Charge Pump Current Adjustable from 250μA to 11.2mA
  • Configurable Status Output
  • SPI Compatible Serial Port Control
  • PLLWizard™ Software Design Tool Support

Typical Application

LTC6946 Typical Application
LTC6946 Typical Application

Description

The LTC®6946 is a high performance, low noise, 5.7GHz phase-locked loop (PLL) with a fully integrated VCO, including a reference divider, phase-frequency detector (PFD) with phase-lock indicator, ultralow noise charge pump, integer feedback divider, and VCO output divider. The charge pump contains selectable high and low voltage clamps useful for VCO monitoring.

The integrated low noise VCO uses no external components. It is internally calibrated to the correct output frequency with no external system support.

The part features a buffered, programmable VCO output divider with a range of 1 through 6, providing a wide frequency range.

Packaging

For complete and up to date package information and drawings, please refer to our packaging page

QFN-28

LTC6946 Package Drawing

Order Info

Package Variations and Pricing

Part Number Package Pins Temp Price (1-99) Price (1k)* RoHS Data
LTC6946IUFD-1 QFN 28 I $8.22 $5.75 View
LTC6946IUFD-1#PBF QFN 28 I $8.22 $5.75 View
LTC6946IUFD-1#TRPBF QFN 28 I $5.81 View
LTC6946IUFD-2#PBF QFN 28 I $8.22 $5.75 View
LTC6946IUFD-2#TRPBF QFN 28 I $5.81 View
LTC6946IUFD-3#PBF QFN 28 I $8.22 $5.75 View
LTC6946IUFD-3#TRPBF QFN 28 I $5.81 View
Buy NowRequest Samples
* The USA list pricing shown is for BUDGETARY USE ONLY, shown in United States dollars (FOB USA per unit for the stated volume), and is subject to change. International prices may differ due to local duties, taxes, fees and exchange rates. For volume-specific price or delivery quotes, please contact your local Linear Technology sales office or authorized distributor.

Demo Boards

Linear Technology offers many demo boards free of charge to qualified customers. Contact your local sales office or distributor to inquire about a demo board. Certain demo boards are also available for sale via credit card on this website. Demo boards are for evaluation purposes only. It remains the customer’s responsibility to verify proper and reliable operation in the actual end application.

Part Number Description Price Documentation
DC1705B-B LTC6946-2 Demo | Ultralow Noise and Spurious 513MHz to 4.91GHz Integer-N Synthesizer with Integrated VCO (Req DC590) $125.00
DC1705C-A LTC6946-1 Demo Board| Ultralow Noise and Spurious 373MHz to 3.74GHz Integer-N Synthesizer with Integrated VCO (Req DC590 or DC2026) $125.00
DC1705C-C LTC6946-3 Demo Board | Ultralow Noise and Spurious 640MHz to 5.79GHz Integer-N Synthesizer with Integrated VCO (Req DC2026) $125.00
Buy Now

Companion Boards

Part Number Description Price Documentation
DC1216A-D 100MHz PLL Synthesizer Reference Clock Source $150.00
DC590B USB Serial Controller for Linear Technology QuikEval Demo Boards $50.00
DC2026B Linduino One Isolated Arduino-Compatible Demonstration Board $75.00
Buy Now
Click here to view our complete list of demo boards

Applications

  • Wireless Base Stations (LTE, WiMAX, W-CDMA, PCS)
  • Broadband Wireless Access
  • Military and Secure Radio
  • Test and Measurement

Product Notifications

Please login to your MyLinear account for notifications of datasheet updates, new document releases and LTspice model announcements for your favorite products. If you do not have a MyLinear account you may Sign Up Now.

Forgot your password? Click here.
Need help? Email mylinear@linear.com with questions and comments.

Design Tools

Linduino

Linduino is an Arduino compatible platform for developing and distributing firmware libraries and code for SPI and I²C-compatible integrated circuits. The Linduino One board interfaces to more than 300 QuikEval demonstration cards, supporting a variety of product types including analog-to-digital converters (ADCs)digital-to-analog converters (DACs)power monitors, and more. Firmware libraries for individual devices are written in C and designed to be portable to a wide variety of processors and microcontrollers. Each library has a demonstration program that can be uploaded to the Linduino One platform to allow the circuit and software to be quickly and easily verified.

Click here for more information on Linduino

PLLWizard

Linear Technology PLLWizard is used to communicate with the LTC6945 and LTC6946 synthesizers. It uses the DC590 controller to translate between USB and SPI-compatible serial communications formats. It also includes advanced PLL design and simulation capabilities. You may use it to:

  • Recommend part parameters based on your frequency plan
  • Design noise-optimized loop filters
  • Simulate loop frequency response and stability
  • Simulate VCO and Reference source noise
  • Simulate output noise characterisics and statistics

Click here to download PLLWizard Software Design Tool

Code

Linduino is Linear Technology's Arduino compatible system for developing and distributing firmware libraries and example code for Linear Technology’s integrated circuits. The code below can be downloaded or copied and pasted into your project. Please visit the Linduino Home Page for demo board, manual and setup information.

This part is Code Supported: There is example code available for this part. The code below may rely on other drivers available in the full library.

Download LTC6946 - DC1705B Linduino.INO File

/*!
DC1705B
LTC6946: Ultralow Noise and Spurious 0.37GHz to 5.7GHz Integer-N Synthesizer with Integrated VCO

@verbatim

  Setup:
    Set the terminal baud rate to 115200 and select the newline terminator.
    Refer to Demo Manual DC1705B.
    Ensure all jumpers are installed in the factory default positions.
    Two power supplies are needed for this demo board: a 5v and a 3.3v supply.

Command Description:

                             *****Main Menu*****

    1-  Read All Registers- Selecting this option will cause all the registers to
        be read, stored to variables, and displayed.

    2-  Read All Registers- Selecting this option causes all the registers to be
        written.

    3-  Enter Loop Design- Selecting this option allows the user to enter a loop
        design. Use PLL Wizard to design the loop.

    4-  Manually Set Registers- Allows the user to set all registers manually.

    5-  Increase by One Step Size- Increases the frequency by one step.

    6-  Decrease by One Step Size- Decreases frequency by one step.

    7-  Sweep- Selecting this option causes a sweep in frequency.

    8-  Disable Ref Out- Selecting this option causes the reference out to be
        disabled.

    9-  Enable Ref Out- Selecting this option causes the reference out to be
        enabled.

    10- Power Down- Selecting this option powers down the LTC6946.

    11- Power up- Selecting this option powers up the LTC6946.

USER INPUT DATA FORMAT:
 decimal : 1024
 hex     : 0x400
 octal   : 02000  (leading 0 "zero")
 binary  : B10000000000
 float   : 1024.0

@endverbatim

http://www.linear.com/product/LTC6946

http://www.linear.com/product/LTC6946#demoboards

REVISION HISTORY
$Revision: 1879 $
$Date: 2013-08-15 08:49:40 -0700 (Thu, 15 Aug 2013) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC6946
*/

#include 
#include 
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "LTC6946.h"
#include 
#include 

// Function Declaration
void print_title();             // Print the title block
void print_prompt();            // Print the main menu
void restore_settings();        // Read the PLL settings from EEPROM
void store_settings();          // Store the PLL Settings to the EEPROM

void menu_1_read_reg();         // Sub-menus
void menu_2_write_all();
void menu_3_enter_loop_design();
void menu_4_manually_set_reg();
void menu_5_increase_one_step();
void menu_6_decrease_one_step();
void menu_7_sweep();
void menu_8_disable_ref_out();
void menu_9_enable_ref_out();
void menu_10_power_down();
void menu_11_power_up();

// Global Variables
static uint8_t REG[12];                //!< Register values to be written or read from
static uint8_t ref_out = 0;            //!< Used to keep track of reference out status
static int8_t demo_board_connected;    //!< Demo Board Name stored in QuikEval EEPROM

#define SWEEP_DELAY  500        //!< The delay between steps for the sweep function

//! Initialize Linduino
void setup()
{
  char demo_name[] = "DC1705";    // Demo Board Name stored in QuikEval EEPROM
  uint8_t data;

  quikeval_SPI_init();      //! Configure the spi port for 4MHz SCK
  quikeval_SPI_connect();   //! Connect SPI to main data port
  quikeval_I2C_init();      //! Configure the EEPROM I2C port for 100kHz
  Serial.begin(115200);     //! Initialize the serial port to the PC

  print_title();

  demo_board_connected = discover_demo_board(demo_name);  //! Checks if correct demo board is connected.

  if (!demo_board_connected)
    while (1);                  //! Does nothing if the demo board is not connected

  Serial.print(demo_board.name);
  Serial.println(F(" was found"));

  restore_settings(); //! Checks if settings was stored to external EEPROM

  print_prompt();
}

//! Repeats Linduino loop
void loop()
{
  uint16_t user_command;          // User input command
  if (Serial.available())         // Check for user input
  {
    user_command = read_int();  //! Reads the user command
    if (user_command != 'm')
      Serial.println(user_command);
    switch (user_command)       //! Prints the appropriate submenu
    {
      case 1:
        menu_1_read_reg();
        break;
      case 2:
        menu_2_write_all();
        break;
      case 3:
        menu_3_enter_loop_design();
        break;
      case 4:
        menu_4_manually_set_reg();
        break;
      case 5:
        menu_5_increase_one_step();
        break;
      case 6:
        menu_6_decrease_one_step();
        break;
      case 7:
        menu_7_sweep();
        break;
      case 8:
        menu_8_disable_ref_out();
        break;
      case 9:
        menu_9_enable_ref_out();
        break;
      case 10:
        menu_10_power_down();
        break;
      case 11:
        menu_11_power_up();
        break;
      default:
        Serial.println(F("Incorrect Option"));
        break;
    }
    Serial.println(F("\n*****************************************************************"));
    print_prompt();
  }
}

// Function Definitions

//! Reads all registers from the LTC6946 and displays them.
void menu_1_read_reg()
{
  // Read All Registers
  Serial.println(F("REG(HEX) Value(HEX)"));
  REG[0] = LTC6946_read(LTC6946_CS, LTC6946_REG_H00);
  Serial.print(F("00       "));
  Serial.println(REG[0], HEX);

  REG[1] = LTC6946_read(LTC6946_CS, LTC6946_REG_H01);
  Serial.print(F("01       "));
  Serial.println(REG[1], HEX);

  REG[2] = LTC6946_read(LTC6946_CS, LTC6946_REG_H02);
  Serial.print(F("02       "));
  Serial.println(REG[2], HEX);

  REG[3] = LTC6946_read(LTC6946_CS, LTC6946_REG_H03);
  Serial.print(F("03       "));
  Serial.println(REG[3], HEX);

  REG[4] = LTC6946_read(LTC6946_CS, LTC6946_REG_H04);
  Serial.print(F("04       "));
  Serial.println(REG[4], HEX);

  REG[5] = LTC6946_read(LTC6946_CS, LTC6946_REG_H05);
  Serial.print(F("05       "));
  Serial.println(REG[5], HEX);

  REG[6] = LTC6946_read(LTC6946_CS, LTC6946_REG_H06);
  Serial.print(F("06       "));
  Serial.println(REG[6], HEX);

  REG[7] = LTC6946_read(LTC6946_CS, LTC6946_REG_H07);
  Serial.print(F("07       "));
  Serial.println(REG[7], HEX);

  REG[8] = LTC6946_read(LTC6946_CS, LTC6946_REG_H08);
  Serial.print(F("08       "));
  Serial.println(REG[8], HEX);

  REG[9] = LTC6946_read(LTC6946_CS, LTC6946_REG_H09);
  Serial.print(F("09       "));
  Serial.println(REG[9], HEX);

  REG[10] = LTC6946_read(LTC6946_CS, LTC6946_REG_H0A);
  Serial.print(F("0A       "));
  Serial.println(REG[10], HEX);

  REG[11] = LTC6946_read(LTC6946_CS, LTC6946_REG_H0B);
  Serial.print(F("0B       "));
  Serial.println(REG[11], HEX);
}

//! Writes all registers to the LTC6946 and displays them.
void menu_2_write_all()
{
  // Write All Registers
  LTC6946_write(LTC6946_CS, LTC6946_REG_H01, REG[1]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H02, REG[2]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H03, REG[3]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H04, REG[4]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H05, REG[5]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H06, REG[6]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H07, REG[7]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H08, REG[8]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H09, REG[9]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H0A, REG[10]);
  Serial.println(F("Registers Have Been Written"));
}

//! Allows the user to enter loop designs.
//! Use PLL Wizard to design the Loop
void menu_3_enter_loop_design()
{
  uint8_t O_DIV;
  uint8_t filt;
  uint8_t LKWIN;
  uint8_t B_DIV;
  uint8_t BST;
  uint8_t rfo;
  uint8_t i_cp;
  uint8_t lkcnt;
  uint8_t O_DIV_possible;
  float f_ref;
  float f_STEP;
  float f_rf;
  float dBm;
  float R_DIV;
  float f_PFD;
  float N_DIV;
  float f_VCO;

  Serial.println();
  Serial.println(F("This loop design function uses simple algorithms"));
  Serial.println(F("to set up the LTC6946. It does not guarantee a stable"));
  Serial.println(F("or optimized loop. It is recommended to use PLL Wizard"));
  Serial.println(F("to create the loop design."));
  Serial.println();

  //Enter Loop Design Loop
  Serial.print(F("Enter f_ref(MHz): "));
  f_ref = read_float();
  Serial.println(f_ref, 4);
  Serial.println();

  Serial.print(F("Enter f_ref power ratio in decibels(dBm): "));
  dBm = read_float();
  Serial.println(dBm, 4);
  Serial.println();

  Serial.print(F("Enter f_step(MHz): "));
  f_STEP = read_float();
  Serial.println(f_STEP, 4);
  Serial.println();

  Serial.print(F("Enter f_rf(MHz): "));
  f_rf = read_float();
  Serial.println(f_rf, 4);
  Serial.println();

  Serial.println(F("Loop Design"));

  if (strcmp(demo_board.product_name, "LTC6946-1") == 0)
    O_DIV_possible = O_divide_1(f_rf, &O_DIV);
  else if (strcmp(demo_board.product_name, "LTC6946-2") == 0)
    O_DIV_possible = O_divide_2(f_rf, &O_DIV);
  else if (strcmp(demo_board.product_name, "LTC6946-3") == 0)
    O_DIV_possible = O_divide_3(f_rf, &O_DIV);

  if (!O_DIV_possible)
  {
    Serial.println();
    Serial.println(F("The desired output frequency cannot be synthesized"));
    Serial.println(F("Please Use PLL Wizard to create and find possible loops"));
    Serial.println();
    return;
  }
  Serial.print(F("O DIV: "));
  Serial.println(O_DIV);

  R_DIV = R_divide(f_ref, &f_STEP, O_DIV);
  Serial.print(F("R DIV: "));
  Serial.println(R_DIV);

  f_PFD = f_pfd(f_ref, R_DIV);
  Serial.print(F("f_PFD: "));
  Serial.println(f_PFD);

  N_DIV = N_divide(f_rf, O_DIV, f_PFD);
  Serial.print(F("N DIV: "));
  Serial.println(N_DIV);

  f_VCO = f_vco(f_ref, N_DIV, R_DIV);
  Serial.print(F("f_VCO: "));
  Serial.println(f_VCO);

  B_DIV = B_div(f_PFD);
  Serial.print(F("B DIV: "));
  Serial.println(B_DIV);

  filt = filter(f_ref);
  Serial.print(F("Filter: "));
  Serial.println(filt);

  LKWIN = lkwin(f_PFD);
  Serial.print(F("LKWIN: "));
  Serial.println(LKWIN);

  union
  {
    uint8_t R[2];
    uint16_t code;
  };
  code = R_DIV;
  if (ref_out == 0)
    REG[2] = LTC6946_PDREFO | LTC6946_MTCAL;
  else
    REG[2] = LTC6946_MTCAL;
  REG[3] = B_DIV |R[1];
  REG[4] = R[0];

  union
  {
    uint8_t N[2];
    uint16_t Code;
  };
  Code = N_DIV;
  REG[5] = N[1];
  REG[6] = N[0];
  REG[7] = LTC6946_ALCCAL | LTC6946_ALCULOK | LTC6946_LKEN | LTC6946_CAL; // Required settings to allow proper loop locking

  BST = bst(dBm);
  Serial.print(F("BST: "));
  Serial.println(BST);

  Serial.println();
  Serial.println(F("RF Output Buffer"));
  Serial.println(F("RFO  P_RF(Differential)  P_RF (Single-Ended)"));
  Serial.println(F("0-   -6dBm               -9dBm"));
  Serial.println(F("1-   -3dBm               -6dBm"));
  Serial.println(F("2-   0dBm                -3dBm"));
  Serial.println(F("3-   3dBm                0dBm"));
  Serial.print(F("Enter RFO: "));

  rfo = read_int();
  Serial.println(rfo);

  if (rfo == 0)
    rfo = LTC6946_RFO_0;
  else if (rfo == 1)
    rfo = LTC6946_RFO_1;
  else if (rfo == 2)
    rfo = LTC6946_RFO_2;
  else
    rfo = LTC6946_RFO_3;

  Serial.println();
  Serial.println(F("Charge Pump Current"));
  Serial.println(F("0- 250 uA"));
  Serial.println(F("1- 350 uA"));
  Serial.println(F("2- 500 uA"));
  Serial.println(F("3- 700 uA"));
  Serial.println(F("4- 1.0 mA"));
  Serial.println(F("5- 1.4 mA"));
  Serial.println(F("6- 2.0 mA"));
  Serial.println(F("7- 2.8 mA"));
  Serial.println(F("8- 4.0 mA"));
  Serial.println(F("9- 5.6 mA"));
  Serial.println(F("10- 8.0 mA"));
  Serial.println(F("11- 11.2 mA"));
  Serial.print(F("Enter I_CP: "));

  i_cp = read_int();
  Serial.println(i_cp);

  switch (i_cp)
  {
    case 0:
      i_cp = LTC6946_CP_0;
      break;
    case 1:
      i_cp = LTC6946_CP_1;
      break;
    case 2:
      i_cp = LTC6946_CP_2;
      break;
    case 3:
      i_cp = LTC6946_CP_3;
      break;
    case 4:
      i_cp = LTC6946_CP_4;
      break;
    case 5:
      i_cp = LTC6946_CP_5;
      break;
    case 6:
      i_cp = LTC6946_CP_6;
      break;
    case 7:
      i_cp = LTC6946_CP_7;
      break;
    case 8:
      i_cp = LTC6946_CP_8;
      break;
    case 9:
      i_cp = LTC6946_CP_9;
      break;
    case 10:
      i_cp = LTC6946_CP_10;
      break;
    default:
      i_cp = LTC6946_CP_11;
      break;
  }

  Serial.println();
  Serial.println(F("LKCNT"));
  Serial.println(F("    count"));
  Serial.println(F("0 - 32"));
  Serial.println(F("1 - 128"));
  Serial.println(F("2 - 512"));
  Serial.println(F("3 - 2048"));
  Serial.print(F("Enter LKCNT: "));

  lkcnt = read_int();
  Serial.println(lkcnt);

  if (lkcnt == 3)
    lkcnt = LTC6946_LKCNT_3;
  else if (lkcnt == 2)
    lkcnt = LTC6946_LKCNT_2;
  else if (lkcnt == 1)
    lkcnt = LTC6946_LKCNT_1;
  else
    lkcnt = LTC6946_LKCNT_0;

  REG[8] = BST | filt | O_DIV | rfo;
  REG[9] = i_cp | LKWIN | lkcnt;
  REG[10] = LTC6946_CPCHI | LTC6946_CPCLO; // Sets charge pump

  store_settings();
}

//! Allows the user to set all registers manually
void menu_4_manually_set_reg()
{
  uint16_t user_command;          // User input command
  // Manually Set Registers
  do
  {
    Serial.println(F("1-REG 0x01"));
    Serial.println(F("2-REG 0x02"));
    Serial.println(F("3-REG 0x03"));
    Serial.println(F("4-REG 0x04"));
    Serial.println(F("5-REG 0x05"));
    Serial.println(F("6-REG 0x06"));
    Serial.println(F("7-REG 0x07"));
    Serial.println(F("8-REG 0x08"));
    Serial.println(F("9-REG 0x09"));
    Serial.println(F("10-REG 0x0A"));
    Serial.println(F("m-Main Menu"));
    Serial.print(F("Enter a command:"));

    user_command = read_int();  // Read the user command
    if (user_command != 'm')
      Serial.println(user_command);

    switch (user_command)
    {
      case 1:
        // REG 0x01
        Serial.print("Enter REG 0x01: ");
        REG[1] = read_int();
        Serial.println(REG[1], HEX);
        break;
      case 2:
        // REG 0x02
        Serial.print("Enter REG 0x02: ");
        REG[2] = read_int();
        Serial.println(REG[2], HEX);
        break;
      case 3:
        // REG 0x03
        Serial.print("Enter REG 0x03: ");
        REG[3] = read_int();
        Serial.println(REG[3], HEX);
        break;
      case 4:
        // REG 0x04
        Serial.print("Enter REG 0x04: ");
        REG[4] = read_int();
        Serial.println(REG[4], HEX);
        break;
      case 5:
        // REG 0x05
        Serial.print("Enter REG 0x05: ");
        REG[5] = read_int();
        Serial.println(REG[5], HEX);
        break;
      case 6:
        // REG 0x06
        Serial.print("Enter REG 0x06: ");
        REG[6] = read_int();
        Serial.println(REG[6], HEX);
        break;
      case 7:
        // REG 0x07
        Serial.print("Enter REG 0x07: ");
        REG[7] = read_int();
        Serial.println(REG[7], HEX);
        break;
      case 8:
        // REG 0x08
        Serial.print("Enter REG 0x08: ");
        REG[8] = read_int();
        Serial.println(REG[8], HEX);
        break;
      case 9:
        // REG 0x09
        Serial.print("Enter REG 0x09: ");
        REG[9] = read_int();
        Serial.println(REG[9], HEX);
        break;
      case 10:
        // REG 0x0A
        Serial.print("Enter REG 0x0A: ");
        REG[10] = read_int();
        Serial.println(REG[10], HEX);
        break;
      default:
        if (user_command != 'm')
          Serial.println("Incorrect Option");
        break;
    }
  }
  while (user_command !='m');
}

//! Increases the frequency by one step
void menu_5_increase_one_step()
{
  union
  {
    uint8_t N[2];
    uint16_t Code;
  };
  // Increase by One Step Size
  N[1] = LTC6946_read(LTC6946_CS, LTC6946_REG_H05);
  N[0] = LTC6946_read(LTC6946_CS, LTC6946_REG_H06);
  Code ++;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);
}

//! Decreases frequency by one step
void menu_6_decrease_one_step()
{
  union
  {
    uint8_t N[2];
    uint16_t Code;
  };
  // decrease by One Step Size
  N[1] = LTC6946_read(LTC6946_CS, LTC6946_REG_H05);
  N[0] = LTC6946_read(LTC6946_CS, LTC6946_REG_H06);
  Code --;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);
}

//! This function causes a sweep in frequency
void menu_7_sweep()
{
  uint8_t data;
  uint16_t sweep_temp;

  union
  {
    uint8_t N[2];
    uint16_t Code;
  };

  // Sweep
  N[1] = LTC6946_read(LTC6946_CS, LTC6946_REG_H05);
  N[0] = LTC6946_read(LTC6946_CS, LTC6946_REG_H06);
  sweep_temp = Code;
  do
  {
    LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
    LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);
    delay(SWEEP_DELAY);
    Code ++;
    Serial.print("N DIV: ");
    Serial.println(Code);
    data = LTC6946_read(LTC6946_CS, LTC6946_REG_H00);
  }
  while ((data && 0x04));

  Code = sweep_temp;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);

  do
  {
    LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
    LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);
    delay(SWEEP_DELAY);
    Code --;
    Serial.print("N DIV: ");
    Serial.println(Code);
    data = LTC6946_read(LTC6946_CS, LTC6946_REG_H00);
  }
  while ((data && 0x04));

  Code = sweep_temp;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H05, N[1]);
  LTC6946_write(LTC6946_CS, LTC6946_REG_H06, N[0]);

  Serial.println("Sweep Has Been Completed");
  Serial.println();
}

//! This function causes the reference out to be disabled
void menu_8_disable_ref_out()
{
  // Turn off Ref Out
  ref_out = 0;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H02, (LTC6946_PDREFO | LTC6946_MTCAL));
  Serial.println("REF Out Has Been Turned Off");
}

//! This function causes the reference out to be enabled
void menu_9_enable_ref_out()
{
  // Turn On Ref Out
  ref_out = 1;
  LTC6946_write(LTC6946_CS, LTC6946_REG_H02, LTC6946_MTCAL);
  Serial.println("REF Out Has Been Turned On");
}

//! This function powers down the LTC6946
void menu_10_power_down()
{
  // Power Down
  if (ref_out == 0)
    LTC6946_write(LTC6946_CS, LTC6946_REG_H02, (LTC6946_PDREFO | LTC6946_MTCAL | LTC6946_PDALL));
  else
    LTC6946_write(LTC6946_CS, LTC6946_REG_H02, (LTC6946_MTCAL | LTC6946_PDALL));
}

//! This function powers up the LTC6946
void menu_11_power_up()
{
  // Power up
  if (ref_out == 0)
    LTC6946_write(LTC6946_CS, LTC6946_REG_H02, (LTC6946_PDREFO | LTC6946_MTCAL));
  else
    LTC6946_write(LTC6946_CS, LTC6946_REG_H02, (LTC6946_MTCAL));
}

//! Prints the title block when program first starts.
void print_title()
{
  Serial.println(F("*****************************************************************"));
  Serial.println(F("* DC1705 Demonstration Program                                  *"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("* This program demonstrates how to send data to the LTC6946     *"));
  Serial.println(F("* Ultra Low Noise & Spurious Integer-N Synthesizer with         *"));
  Serial.println(F("* Integrated VCO.                                               *"));
  Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
  Serial.println(F("*                                                               *"));
  Serial.println(F("*****************************************************************"));
  Serial.println();
}

//! Prints main menu.
void print_prompt()
{
  Serial.println(F("\nCommand Summary:"));
  Serial.println(F("  1-Read All Registers"));
  Serial.println(F("  2-Write All Registers"));
  Serial.println(F("  3-Design Loop"));
  Serial.println(F("  4-Manually Set Register"));
  Serial.println(F("  5-Increase by One Step Size"));
  Serial.println(F("  6-Decrease by One Step Size"));
  Serial.println(F("  7-Sweep Through Step Sizes"));
  Serial.println(F("  8-Disable Ref Out"));
  Serial.println(F("  9-Enable Ref Out"));
  Serial.println(F("  10-Power Down"));
  Serial.println(F("  11-Power Up"));
  Serial.println("");
  Serial.print(F("Enter a command:"));
}

//! Store PLL settings to nonvolatile EEPROM on demo board
void store_settings()
// Store the PLL Settings to the EEPROM
{
  eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, EEPROM_CAL_STATUS_ADDRESS);         // Cal key
  for (uint8_t i = 2; i <= 10 ; i++)
    eeprom_write_byte(EEPROM_I2C_ADDRESS,(char) REG[i], EEPROM_CAL_STATUS_ADDRESS + i);
  Serial.println(F("PLL Settings Stored to EEPROM"));
}

//! Read stored PLL settings from nonvolatile EEPROM on demo board
void restore_settings()
// Read the PLL settings from EEPROM
{
  int16_t cal_key;
  // read the cal key from the EEPROM
  eeprom_read_int16(EEPROM_I2C_ADDRESS, &cal_key, EEPROM_CAL_STATUS_ADDRESS);
  if (cal_key == EEPROM_CAL_KEY)
  {
    // PLL Settings has been stored, read PLL Settings
    for (uint8_t i = 2; i <= 10 ; i++)
      eeprom_read_byte(EEPROM_I2C_ADDRESS,(char *) ®[i], EEPROM_CAL_STATUS_ADDRESS + i);
    Serial.println(F("PLL Settings Restored"));
  }
  else
    Serial.println(F("PLL Settings not found"));
}

Download LTC6946 - DC1705C.INO

/*!
DC1705C
LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO

@verbatim

  Setup:
    Set the terminal baud rate to 115200 and select the newline terminator.
    Refer to Demo Manual DC1705C.
    Ensure all jumpers are installed in the factory default positions.
    Two power supplies are needed for this demo board: a 5v and a 3.3v supply.
    A reference frequency is also needed for this demo board, refer to the
    DC1705 Demo Manual for details.
    
    
Command Description:

                             *****Main Menu*****
    1-  Load Default Settings- Loads the SPI map that is identical to file 
        LTC6946-x_100MHz.pllset that is supplied with the PLLWizard and mentioned
        in the DC1705C user's manual.  It assumes a 100MHz reference input and the
        default DC1705C loop filter.  It should output a 907MHz signal on RF+/-.
        
        ** If you want to use a different loop filter, reference frequency or different
        register settings.  Please use PLLWizard for the loop filter design and initial
        device setup.  The register settings from PLLWizard can be entered into menu option 2.
        
    2-  READ/WRITE to Registers Addresses- Selecting this option will cause all the registers to
        be read, stored to variables, and displayed.  The user will then have the option
        to write to one register address at a time.

    3-  READ/WRITE to Registers Fields- Selecting this option will allow the user
        to read or write to one register field name at a time. 
        
    4-  This function calculates and programs OD, ND, NUM based on the desired Frf,
        the reference frequency, and the current RD value.  Linduino One (Arduino Uno) are 
        limited to 32 bit floats, int and doubles.  Significant rounding errors are created 
        with this 32 bit limitation.  Therefore, this function uses 64bit math functions 
        specifically created to overcome this limitation.  After OD, ND, and NUM are programmed, 
        the program calibrates the LTC6946.  If other register need change see menu 2 or menu 3.
                 
    5-  This function stores the current SPI settings in the demo boards EEPROM
        
    6-  This function loads SPI settings from the demo boards EEPROM to the device

USER INPUT DATA FORMAT:
 decimal : 1024
 hex     : 0x400
 octal   : 02000  (leading 0 "zero")
 binary  : B10000000000
 float   : 1024.0

@endverbatim

http://www.linear.com/product/LTC6946

http://www.linear.com/product/LTC6946#demoboards

REVISION HISTORY
$Revision: 3018 $
$Date: 2014-12-01 15:53:20 -0800 (Mon, 01 Dec 2014) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC6946
*/

#include 
#include 
#include "Linduino.h"
#include "LT_SPI.h"
#include "UserInterface.h"
#include "LT_I2C.h"
#include "QuikEval_EEPROM.h"
#include "LTC6946.h"
#include 
#include 

// Function Declaration
void print_title();             // Print the title block
void print_prompt();            // Print the main menu
void menu_1_load_default_settings();  // Sub-menus
void menu_2_RW_to_reg_addresss();         
void menu_3_RW_to_reg_field();
void menu_4_set_frf();
void menu_5_store_settings();
void menu_6_restore_settings();

// Global Variables
static uint8_t ref_out = 0;            //!< Used to keep track of reference out status
static int8_t demo_board_connected;    //!< Demo Board Name stored in QuikEval EEPROM
uint8_t First_Run=0;                   //!< if first time through loop = 0, otherwise=1


/* ------------------------------------------------------------------------- */
//! Initialize Linduino
//! @return void
void setup() {
char demo_name[] = "DC1705";    // Demo Board Name stored in QuikEval EEPROM
uint8_t data;

quikeval_SPI_init();      //! Configure the spi port for 4MHz SCK
quikeval_SPI_connect();   //! Connect SPI to main data port
quikeval_I2C_init();      //! Configure the EEPROM I2C port for 100kHz
Serial.begin(115200);     //! Initialize the serial port to the PC
LTC6946_init();
print_title();

demo_board_connected = discover_demo_board(demo_name);  //! Checks if correct demo board is connected.

if (!demo_board_connected)
   while (1);                  //! Does nothing if the demo board is not connected

Serial.print(demo_board.name);
Serial.println(F(" was found"));

print_prompt();
} // end of setup()


/* ------------------------------------------------------------------------- */
//! Repeats Linduino loop
//! @return void
void loop(){
uint16_t user_command;          // User input command
  
if (Serial.available()) {        // Check for user input
   if(First_Run==0){
      First_Run=1;
      } 
 
    user_command = read_int();  //! Reads the user command
    if (user_command != 'm')
      Serial.println(user_command);
    
    switch (user_command) {     //! Prints the appropriate submenu
       case 1:
        menu_1_load_default_settings();
       break;
        
       case 2:
        menu_2_RW_to_reg_addresss(); 
       break;
        
       case 3:
        menu_3_RW_to_reg_field();
       break;
        
       case 4:
        menu_4_set_frf();
       break; 
       
       case 5:
        menu_5_store_settings(); 
       break; 
       
       case 6:
         menu_6_restore_settings(); 
       break; 
       
       default:
        Serial.println(F("Incorrect Option"));
       break;
    } // end of switch statement
  Serial.println(F("\n*****************************************************************"));
  print_prompt();
  } // end of if statement
} // end of loop()

// Function Definitions
/* ------------------------------------------------------------------------- */
//! Menu 1: Load Default SPI Register Settings
//!  This function identifies which of the 4 LTC6946 frequency versions are connected.
//!  Based on the version connected, this function loads the register settings referenced
//!  in the DC1705C demo manual's quick start section.
//!  The register settings loaded are the same as PLL WIZARDS pllset files 
//!  DC1705-x(LTC6946-x)100MHz.pllset (where x=1,2,3,or 4)
//!  The setting loaded with this function assume the LTC6946's reference is set to 100MHz and
//!  the DC1705C's loop filter has not been modified.
//! @return void
void menu_1_load_default_settings(){

// select which default register setting to load based on part number
if (demo_board.product_name[8]=='1')   // if this is a LTC6946-1 
   set_LTC6946_ALLREGS(LTC6946_CS, 0x04,0x0C,0x00,0x64,0x0A,0x8C,0x33,0x9B,0x8B,0x00); 
else if (demo_board.product_name[8]=='2')  // if this is a LTC6946-2
   set_LTC6946_ALLREGS(LTC6946_CS, 0x04,0x0C,0x00,0x64,0x0E,0x10,0x33,0x9C,0x8B,0x00); 
else if (demo_board.product_name[8]=='3')  // if this is a LTC6946-3
   set_LTC6946_ALLREGS(LTC6946_CS, 0x04,0x0C,0x00,0x64,0x11,0x94,0x33,0x9D,0x8B,0x00); 
else if (demo_board.product_name[8]=='4')  // if this is a LTC6946-4
   set_LTC6946_ALLREGS(LTC6946_CS, 0x04,0x0C,0x00,0x64,0x11,0x94,0x33,0x9D,0x8B,0x00);
else {
   Serial.print("No default file for this board:  ");
   Serial.println(demo_board.product_name);
   }  // end if-then-else statement
  
Serial.println(F("Registers Have Been Written"));
} // end menu_1_load_default_settings function


/* ------------------------------------------------------------------------- */
//! Menu 2: Reads and/or Writes the SPI register address
//!  This function reads and displays all SPI register address settings in HEX format.
//!  It then provides an option to modify(write to) individual registers one at time
//!
//!  EXAMPLE:
//!  - 0- ADDR00 = 0x40 (read only) 
//!  - 1- ADDR01 = 0x04
//!  - ....
//!  - 10- ADDR0A = 0x00
//!  - 11- ADDR0B = 0x41 (read only) 
//!  - 0 - Return to Main Menu
//!  - Enter a command (1-10 to modify register, or '0' to return to Main Menu): 
//! @return void
void menu_2_RW_to_reg_addresss(){
uint8_t i, regval, user_regval, num_reg;
uint16_t user_address;          // User input command

num_reg = get_LTC6946_REGSIZE();
user_address=1;
// Read/Write loop, can exit loop by choosing '0'
while  (user_address != 0) {
   Serial.println(F("\n*****************************************************************"));
   // Read All Registers and display results
   for(i=0; i0 && user_address<(num_reg-1)) {
      Serial.print("What value should ADDR");
      Serial.print(user_address);
      Serial.print(" be set to (ex: HEX format 0xff): ");
      user_regval = read_int();  //! Reads the user command
      Serial.println(user_regval);

      // writes new setting to part
      LTC6946_write(LTC6946_CS, (uint8_t)user_address, user_regval);
      } // end if statement
   } // end while loop
}  // end menu_2_RW_to_reg_addresss


/* ------------------------------------------------------------------------- */
//! Support function for function menu_3_RW_to_reg_field  
//!  displays current state of select field 
//!  provides user the option to write to that field or return to menu
//!  @return field value (user input) that will be written to part
long field_menu_RW(long field_val,       //!< current state of the selected field
                   char field_name[],    //!< SPI Field name selected
                   uint8_t f             //!< SPI field identifier identifies selected fields information in SPI MAP arrays
                   ){
long usr_field_val;
uint8_t field_size, i;
long max_num=1, pow2=1;
  
Serial.print("CURRENT STATE (HEX): ");
Serial.print(field_name);
Serial.print("= 0x");
Serial.println(field_val, HEX);

if(get_LTC6946_SPI_FIELD_RW(f)==0){     
   field_size=get_LTC6946_SPI_FIELD_NUMBITS(f);
   for(i=1; i=0 && usr_field_val<=max_num){
      Serial.println(usr_field_val);
      return usr_field_val;
      }
   else {
      return field_val;
      } // end of if statement
   } // end of if statement
} // end of field_menu_RW


/* ------------------------------------------------------------------------- */
//! Menu 3: Reads and/or Writes individual SPI fields
//!  This function provides the user with a list of all SPI fields.
//!  The user can select a SPI field to read its current value.
//!  Then the user will be provided with an option to write to that field
//!  or return to the selection menu.
//!
//!  EXAMPLE:
//!  - 1-ALCCAL     15-CPMID     29-PDALL  
//!  - 2-ALCEN      16-CPRST     30-PDOUT
//!  - ....
//!  - 13-CPDN      27-OMUTE     41-x
//!  - 14-CPINV     28-PART *
//!  - 0 - Return to Main Menu
//!  - * = READ ONLY FIELD
//!  - Enter a command (1-41 to modify register, or '0' to return to Main Menu): 
//! @return void
void menu_3_RW_to_reg_field(){
uint8_t  field_num;
long field_val;

field_num=1;
// Read/Write loop, can exit loop by choosing 'm'
while  (field_num != 0) {
   Serial.println(F("\n*****************************************************************"));
   // Select Fields to read and write to
   Serial.print(F("1-ALCCAL     15-CPMID     29-PDALL\n"));
   Serial.print(F("2-ALCEN      16-CPRST     30-PDOUT\n"));
   Serial.print(F("3-ALCHI *    17-CPUP      31-PDPLL\n"));
   Serial.print(F("4-ALCLO *    18-CPWIDE    32-PDREFO\n"));
   Serial.print(F("5-ALCMON     19-FILT      33-PDVCO\n"));
   Serial.print(F("6-ALCULOK    20-LKCT      34-POR\n"));
   Serial.print(F("7-BD         21-LKEN      35-RD\n"));
   Serial.print(F("8-BST        22-LKWIN     36-REV *\n"));
   Serial.print(F("9-CAL        23-LOCK *    37-RFO\n"));
   Serial.print(F("10-CP        24-MTCAL     38-THI *\n"));
   Serial.print(F("11-CPCHI     25-ND        39-TLO *\n"));
   Serial.print(F("12-CPCLO     26-OD        40-UNLOK *\n"));
   Serial.print(F("13-CPDN      27-OMUTE     41-x\n"));
   Serial.print(F("14-CPINV     28-PART *\n"));
   Serial.print("0 - Return to Main Menu\n");
   Serial.print("* = READ ONLY FIELD\n\n");

   Serial.print("Enter a command (1-41 to modify register, or '0' to return to Main Menu): ");
   field_num = read_int();  //! Reads the user command
   Serial.println(field_num);
  
   // User input: enter new setting for selected register
   if (field_num != 0) {
      switch (field_num) {      //! Prints the appropriate submenu
         case LTC6946_ALCCAL:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCCAL);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCCAL",LTC6946_ALCCAL);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCCAL, field_val);}   // updates selected field
         break;

         case LTC6946_ALCEN:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCEN);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCEN",LTC6946_ALCEN);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCEN, field_val);}   // updates selected field
         break;

         case LTC6946_ALCHI:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCHI);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCHI",LTC6946_ALCHI);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCHI, field_val);}   // updates selected field
         break;

         case LTC6946_ALCLO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCLO);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCLO",LTC6946_ALCLO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCLO, field_val);}   // updates selected field
         break;

         case LTC6946_ALCMON:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCMON);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCMON",LTC6946_ALCMON);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCMON, field_val);}   // updates selected field
         break;

         case LTC6946_ALCULOK:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ALCULOK);    // reads selected field   
           field_val=field_menu_RW(field_val,"ALCULOK",LTC6946_ALCULOK);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ALCULOK, field_val);}   // updates selected field
         break;

         case LTC6946_BD:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_BD);    // reads selected field   
           field_val=field_menu_RW(field_val,"BD",LTC6946_BD);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_BD, field_val);}   // updates selected field
         break;

         case LTC6946_BST:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_BST);    // reads selected field   
           field_val=field_menu_RW(field_val,"BST",LTC6946_BST);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_BST, field_val);}   // updates selected field
         break;

         case LTC6946_CAL:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CAL);    // reads selected field   
           field_val=field_menu_RW(field_val,"CAL",LTC6946_CAL);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CAL, field_val);}   // updates selected field
         break;

         case LTC6946_CP:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CP);    // reads selected field   
           field_val=field_menu_RW(field_val,"CP",LTC6946_CP);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CP, field_val);}   // updates selected field
         break;

         case LTC6946_CPCHI:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPCHI);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPCHI",LTC6946_CPCHI);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPCHI, field_val);}   // updates selected field
         break;

         case LTC6946_CPCLO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPCLO);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPCLO",LTC6946_CPCLO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPCLO, field_val);}   // updates selected field
         break;

         case LTC6946_CPDN:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPDN);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPDN",LTC6946_CPDN);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPDN, field_val);}   // updates selected field
         break;

         case LTC6946_CPINV:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPINV);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPINV",LTC6946_CPINV);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPINV, field_val);}   // updates selected field
         break;

         case LTC6946_CPMID:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPMID);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPMID",LTC6946_CPMID);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPMID, field_val);}   // updates selected field
         break;

         case LTC6946_CPRST:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPRST);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPRST",LTC6946_CPRST);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPRST, field_val);}   // updates selected field
         break;

         case LTC6946_CPUP:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPUP);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPUP",LTC6946_CPUP);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPUP, field_val);}   // updates selected field
         break;

         case LTC6946_CPWIDE:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_CPWIDE);    // reads selected field   
           field_val=field_menu_RW(field_val,"CPWIDE",LTC6946_CPWIDE);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_CPWIDE, field_val);}   // updates selected field
         break;

         case LTC6946_FILT:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_FILT);    // reads selected field   
           field_val=field_menu_RW(field_val,"FILT",LTC6946_FILT);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_FILT, field_val);}   // updates selected field
         break;

         case LTC6946_LKCT:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_LKCT);    // reads selected field   
           field_val=field_menu_RW(field_val,"LKCT",LTC6946_LKCT);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_LKCT, field_val);}   // updates selected field
         break;

         case LTC6946_LKEN:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_LKEN);    // reads selected field   
           field_val=field_menu_RW(field_val,"LKEN",LTC6946_LKEN);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_LKEN, field_val);}   // updates selected field
         break;

         case LTC6946_LKWIN:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_LKWIN);    // reads selected field   
           field_val=field_menu_RW(field_val,"LKWIN",LTC6946_LKWIN);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_LKWIN, field_val);}   // updates selected field
         break;

         case LTC6946_LOCK:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_LOCK);    // reads selected field   
           field_val=field_menu_RW(field_val,"LOCK",LTC6946_LOCK);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_LOCK, field_val);}   // updates selected field
         break;

         case LTC6946_MTCAL:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_MTCAL);    // reads selected field   
           field_val=field_menu_RW(field_val,"MTCAL",LTC6946_MTCAL);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_MTCAL, field_val);}   // updates selected field
         break;

         case LTC6946_ND:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ND);    // reads selected field   
           field_val=field_menu_RW(field_val,"ND",LTC6946_ND);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_ND, field_val);}   // updates selected field
         break;

         case LTC6946_OD:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_OD);    // reads selected field   
           field_val=field_menu_RW(field_val,"OD",LTC6946_OD);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_OD, field_val);}   // updates selected field
         break;

         case LTC6946_OMUTE:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_OMUTE);    // reads selected field   
           field_val=field_menu_RW(field_val,"OMUTE",LTC6946_OMUTE);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_OMUTE, field_val);}   // updates selected field
         break;

         case LTC6946_PART:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PART);    // reads selected field   
           field_val=field_menu_RW(field_val,"PART",LTC6946_PART);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PART, field_val);}   // updates selected field
         break;

         case LTC6946_PDALL:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PDALL);    // reads selected field   
           field_val=field_menu_RW(field_val,"PDALL",LTC6946_PDALL);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PDALL, field_val);}   // updates selected field
         break;

         case LTC6946_PDOUT:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PDOUT);    // reads selected field   
           field_val=field_menu_RW(field_val,"PDOUT",LTC6946_PDOUT);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PDOUT, field_val);}   // updates selected field
         break;

         case LTC6946_PDPLL:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PDPLL);    // reads selected field   
           field_val=field_menu_RW(field_val,"PDPLL",LTC6946_PDPLL);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PDPLL, field_val);}   // updates selected field
         break;

         case LTC6946_PDREFO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PDREFO);    // reads selected field   
           field_val=field_menu_RW(field_val,"PDREFO",LTC6946_PDREFO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PDREFO, field_val);}   // updates selected field
         break;

         case LTC6946_PDVCO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_PDVCO);    // reads selected field   
           field_val=field_menu_RW(field_val,"PDVCO",LTC6946_PDVCO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_PDVCO, field_val);}   // updates selected field
         break;

         case LTC6946_POR:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_POR);    // reads selected field   
           field_val=field_menu_RW(field_val,"POR",LTC6946_POR);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_POR, field_val);}   // updates selected field
         break;

         case LTC6946_RD:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_RD);    // reads selected field   
           field_val=field_menu_RW(field_val,"RD",LTC6946_RD);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_RD, field_val);}   // updates selected field
         break;

         case LTC6946_REV:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_REV);    // reads selected field   
           field_val=field_menu_RW(field_val,"REV",LTC6946_REV);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_REV, field_val);}   // updates selected field
         break;

         case LTC6946_RFO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_RFO);    // reads selected field   
           field_val=field_menu_RW(field_val,"RFO",LTC6946_RFO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_RFO, field_val);}   // updates selected field
         break;

         case LTC6946_THI:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_THI);    // reads selected field   
           field_val=field_menu_RW(field_val,"THI",LTC6946_THI);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_THI, field_val);}   // updates selected field
         break;

         case LTC6946_TLO:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_TLO);    // reads selected field   
           field_val=field_menu_RW(field_val,"TLO",LTC6946_TLO);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_TLO, field_val);}   // updates selected field
         break;

         case LTC6946_UNLOK:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_UNLOK);    // reads selected field   
           field_val=field_menu_RW(field_val,"UNLOK",LTC6946_UNLOK);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_UNLOK, field_val);}   // updates selected field
         break;

         case LTC6946_x:
           field_val=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_x);    // reads selected field   
           field_val=field_menu_RW(field_val,"x",LTC6946_x);      // user interface control and printout
           if(field_val>-1)  {set_LTC6946_SPI_FIELD(LTC6946_CS, LTC6946_x, field_val);}   // updates selected field
         break;
         }  // end of switch statement
      } // end if user_command != 0 statement
   } // end while loop
}  // end menu_3_RW_to_reg_field function

/* ------------------------------------------------------------------------- */
//! verifies reference frequency is within datasheet specifications
void LTC6946_Ref_Freq_Verification(){
unsigned long temp_val, temp_fref_MHz, temp_fref_Hz;
boolean valid_input=false;

// USER INPUT
valid_input=false;


while (valid_input==false) {
   temp_fref_MHz=get_LTC6946_global_fref_MHz();
   temp_fref_Hz=get_LTC6946_global_fref_Hz();
   Serial.print(F("\nThe Reference frequency will be entered with 2 integers\n"));
   Serial.print(F("1st number is the MHZ portion, the 2nd number is Hz portion\n"));
   Serial.print(F(" - Example: A. 100\n"));
   Serial.print(F("            B. 25\n"));
   Serial.print(F("   equates to 100.000025MHZ\n\n"));
   Serial.print(F("A. What is the MHz portion of the Reference Input Frequency(MHZ)? ["));
   Serial.print(temp_fref_MHz);
   Serial.print(F("]: "));
   temp_val = read_float();  //! Reads the user command
   // if user selects enter, keep same Fref.  Otherwise set Fref and verify
   if(temp_val!=0) temp_fref_MHz = abs(temp_val);
   Serial.println(temp_fref_MHz);

   Serial.print(F("B. What is the sub-MHz portion of the Reference Input Frequency(HZ)? "));
   temp_val = read_float();  //! Reads the user command
   temp_fref_Hz = abs(temp_val);   
   Serial.println(temp_fref_Hz);

   // if valid input print the following to the screen
   if(temp_fref_MHz >=LTC6946_MIN_REF_FREQ & temp_fref_MHz <= LTC6946_MAX_REF_FREQ) {
      set_LTC6946_global_fref(temp_fref_MHz,temp_fref_Hz);
      temp_val= temp_fref_MHz*OneMHz + temp_fref_Hz;
      Serial.print(F("Reference Frequency set to ")); 
      Serial.print(temp_val);
      Serial.println(F("Hz"));
      valid_input=true;
      }
    else {
      Serial.print(F("Reference Frequency must be between 10MHz and 250MHz\n"));
      }  // end of if-else
   } // end of while
}  // end of LTC6946_Ref_Freq_Verification


/* ------------------------------------------------------------------------- */
//! verifies frf frequency is within datasheet specifications
void LTC6946_Fout_Freq_Verification(char part_version[]){
unsigned long odiv, temp_fout_MHz, temp_fout_Hz, temp_val;
unsigned long frf[2];
boolean valid_input=false;

// USER INPUT
temp_fout_MHz=get_LTC6946_global_frf_MHz();
temp_fout_Hz=get_LTC6946_global_frf_Hz();

while(valid_input==false){
   Serial.print(F("\nThe Output Frequency (Frf) will be entered with 2 integers\n"));
   Serial.print(F("1st number is the MHZ portion, the 2nd number is Hz portion\n"));
   Serial.print(F("C. What is the MHz portion of the Output Frequency(MHZ)? ["));
   Serial.print(temp_fout_MHz);
   Serial.print(F("]: "));
   temp_val = read_int();  //! Reads the user command
   // if user selects enter, keep same Fout.  Otherwise set Fout and verify
   if(temp_val!=0) temp_fout_MHz = abs(temp_val);
   Serial.println(temp_fout_MHz);

   Serial.print(F("D. What is the Hz portion of the Output Frequency(HZ)? "));
   temp_val = read_int();  //! Reads the user command
   temp_fout_Hz = abs(temp_val);
   Serial.println(temp_fout_Hz);
   
   HZto64(frf,temp_fout_MHz,temp_fout_Hz);  // convert to 64 bit integer

   // verify desired frequency falls within a divider range (1-6)  
   odiv = LTC6946_calc_odiv(part_version, frf);
   valid_input=false;
   if((odiv>=1) && (odiv<=6)) valid_input=true;
 
   // if valid input print the following to the screen
   if(valid_input==true) {
      set_LTC6946_global_frf(temp_fout_MHz,temp_fout_Hz);
      if(temp_fout_MHz < 4294) {
         temp_val= temp_fout_MHz*OneMHz + temp_fout_Hz;
         Serial.print(F("Desired Output Frequency is ")); 
         Serial.print(temp_val);
         Serial.println(F("Hz"));
         }
      else {  // over flow condition
         Serial.print(F("Desired Output Frequency is ")); 
         Serial.print(temp_fout_MHz);
         Serial.print(F("MHz + "));
         Serial.print(temp_fout_Hz);
         Serial.println(F("Hz"));
         }
       }
    // if invalid input print the following to the screen
   else {
      Serial.println(F("Invalid Fout frequency chosen"));
      } // end of if/else (valid_input==true)
   } // end of while(valid_input=false)
} // end of Fout_Freq_Verification


/* ------------------------------------------------------------------------- */
//! Menu 4: Calculates and programs OD, ND based on desired Frf
//!  This function calculates and programs OD, ND based on desired Frf,
//!  the reference frequency, and current RD value.  
//!  Linduino One (Arduino Uno) are limited to 32 bit floats, int and doubles.
//!  Significant rounding errors are created with this 32 bit limitation.  Therefore,
//!  This function uses 64bit math functions specifically created to overcome this limitation.
//!  After OD, ND are programmed, the program calibrates the LTC6946
//!  If RD needs to change see menu 2 or menu 3
//! @return void
void menu_4_set_frf(){
Serial.print(F("\nThis function calculates and programs OD and ND\n"));
Serial.print(F("based on the value input for Frf and Fref.  It then calibrates the part.\n"));
Serial.print(F("It assumes all other register settings are correct\n"));
Serial.print(F("The PLLWizard tool can verify the correctness of the other register settings.\n"));

LTC6946_Ref_Freq_Verification();
LTC6946_Fout_Freq_Verification(demo_board.product_name);
LTC6946_set_frf(demo_board.product_name);
}

/* ------------------------------------------------------------------------- */
//! Store PLL settings to nonvolatile EEPROM on demo board
//! @return void
void menu_5_store_settings() {
// Store the PLL Settings to the EEPROM
uint8_t regval;

uint8_t addr_offset;
uint8_t num_reg;

addr_offset=2;
num_reg = get_LTC6946_REGSIZE();
 
eeprom_write_int16(EEPROM_I2C_ADDRESS, EEPROM_CAL_KEY, EEPROM_CAL_STATUS_ADDRESS);         // Cal key
  
for (uint8_t i = 0; i <= num_reg ; i++){
   regval = LTC6946_read(LTC6946_CS,i);
   eeprom_write_byte(EEPROM_I2C_ADDRESS,(char) regval, EEPROM_CAL_STATUS_ADDRESS+ i+addr_offset);
   }
Serial.println(F("PLL Settings Stored to EEPROM"));

}


/* ------------------------------------------------------------------------- */
//! Read stored PLL settings from nonvolatile EEPROM on demo board
//! @return void
void menu_6_restore_settings() {
// Read the PLL settings from EEPROM
int16_t cal_key;
uint8_t regval;
uint8_t user_address;

uint8_t addr_offset;
uint8_t num_reg;

addr_offset=2;
num_reg = get_LTC6946_REGSIZE();

// read the cal key from the EEPROM
eeprom_read_int16(EEPROM_I2C_ADDRESS, &cal_key, EEPROM_CAL_STATUS_ADDRESS);
if (cal_key == EEPROM_CAL_KEY) {
   // PLL Settings has been stored, read PLL Settings
   user_address=2;
   for (uint8_t i = 0; i <= num_reg ; i++) {
      eeprom_read_byte(EEPROM_I2C_ADDRESS,(char *) ®val, EEPROM_CAL_STATUS_ADDRESS + i+addr_offset);
      LTC6946_write(LTC6946_CS, (uint8_t)i, regval);
      user_address++;
      }
   Serial.println(F("PLL Settings Restored"));
   }
else {
   Serial.println(F("PLL Settings not found"));
   }

}

/* ------------------------------------------------------------------------- */
//!    Prints the title block when program first starts.
void print_title() {
  
Serial.println(F("*****************************************************************"));
Serial.println(F("* DC1705 Demonstration Program                                  *"));
Serial.println(F("*                                                               *"));
Serial.println(F("* This program demonstrates how to send data to the LTC6946     *"));
Serial.println(F("* Ultra Low Noise & Spurious IntegerN Synthesizer with          *"));
Serial.println(F("* Integrated VCO.                                               *"));
Serial.println(F("* Set the baud rate to 115200 and select the newline terminator.*"));
Serial.println(F("*                                                               *"));
Serial.println(F("* For loop filter design please use the PLL Wizard software.    *"));
Serial.println(F("* - It is recommended to use Pll Wizard to determine the        *"));
Serial.println(F("* correct SPI register values for the initial setup.  These     *"));
Serial.println(F("* values can be entered into this program via menu option 2     *"));
Serial.println(F("* below.  These values can then be stored and recalled from the *"));
Serial.println(F("* DC1705 EEPROM using options 5 and 6 below.                    *"));
Serial.println(F("*****************************************************************"));
Serial.println();
} // end of print_title


/* ------------------------------------------------------------------------- */
//!    Prints main menu.
void print_prompt() {
  
Serial.println(F("\nCommand Summary:"));
Serial.println(F("  1-Load Default Settings (same as the PLL Wizard's DC1705-x(LTC6946-x)100MHz.pllset settings)"));
Serial.println(F("  2-READ/WRITE to Registers Addresses"));
Serial.println(F("  3-READ/WRITE to Registers Fields"));
Serial.println(F("  4-Set Output Frequency (Frf)"));
Serial.println(F("  5-Store LTC6946 SPI settings to the DC1705's EEPROM"));
Serial.println(F("  6-Restore LTC6946 SPI settings from the DC1705's EEPROM"));
Serial.println("");
Serial.print(F("Enter a command: "));
} // end of print_prompt


Download LTC6946 Linduino .CPP File

/*!
    LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO

@verbatim

The LTC®6946 is a high performance, low noise, 6.39GHz
phase-locked loop (PLL) with a fully integrated VCO,
including a reference divider, phase-frequency detector
(PFD) with phase-lock indicator, ultralow noise charge
pump, integer feedback divider, and VCO output divider.
The charge pump contains selectable high and low voltage
clamps useful for VCO monitoring.

The integrated low noise VCO uses no external components.
It is internally calibrated to the correct output frequency
with no external system support.

The part features a buffered, programmable VCO output
divider with a range of 1 through 6, providing a wide
frequency range.

@endverbatim


http://www.linear.com/product/LTC6946

http://www.linear.com/product/LTC6946#demoboards

REVISION HISTORY
$Revision: 3018 $
$Date: 2014-12-01 15:53:20 -0800 (Mon, 01 Dec 2014) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

//! @defgroup LTC6946 LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO

/*! @file
    @ingroup LTC6946
    Library for LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO
*/

#include 
#include 
#include "Linduino.h"
#include "UserInterface.h"
#include "LT_SPI.h"
#include "LTC6946.h"
#include 

uint8_t LTC6946_reg[LTC6946_NUM_REGADDR];               //!< number of LTC6946 spi addresses  
uint8_t LTC6946_spi_map[(LTC6946_NUM_REGFIELD+1)][4];   //!< LTC6946 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability

unsigned long LTC6946_Fref_MHz = 100;                   //!< Default Fref frequency - MHz portion (xxx);  Fref = xxx, yyy,yyy
unsigned long LTC6946_Fref_Hz = 0;                      //!< Default Fref frequency - Hz portion (yyy,yyy);  Fref = x,xxx, yyy,yyy
unsigned long LTC6946_Frf_MHz = 900;                    //!< Default Frf frequency - MHz portion (xxxx);  Frf = x,xxx, yyy,yyy
unsigned long LTC6946_Frf_Hz  = 0;                      //!< Default Frf frequency - Hz portion (yyy,yyy);  Frf = x,xxx, yyy,yyy

unsigned long zero64[]={0,0}; //!< for 64bit math functions

/* -------------------------------------------------------------------------
  FUNCTION: LTC6946_read
  - reads 8 bit Data field to LTC6946.
  - has to shift data by one bit to account for RW bit
 -------------------------------------------------------------------------- */
uint8_t LTC6946_read(uint8_t cs, int8_t address) {
int8_t address_shift;
LT_union_int16_2bytes rx;
  
address_shift =(address << 1) | 0x01; // shift to left to account for R/W bit, set bit high for read
spi_transfer_word(cs, address_shift<<8 , &rx.LT_uint16);
  
LTC6946_reg[address]=rx.LT_byte[0];
return(rx.LT_byte[0]);
}


/* -------------------------------------------------------------------------
  FUNCTION: LTC6946_read_field
  For SPI FIELDS located in 1 or multiple address location
  - reads specific address locations
  - identifies and returns specific field in question
    - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
--------------------------------------------------------------------------- */
 long LTC6946_read_field(uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits){
 int bit_shift, i, num_reg;
 long field_val, maskbits, pow2;

num_reg=0;
field_val=0;
// determines how many register are used
do {
   bit_shift = (MSB_loc+1)- (numbits-num_reg*8);   // determines bit_shift for last register location
   field_val=LTC6946_read(cs, (address+num_reg))+(field_val<<8);  // reads current address locations, shifts previous address location 8 bits
   num_reg++;
}while ((bit_shift<0) && (num_reg<4));
  
// creates a bit mask for complete word, 
maskbits = 1;
pow2=1;
for(i=1, maskbits=1;i>bit_shift) &maskbits; 
return field_val;
}

/* -------------------------------------------------------------------------
  FUNCTION: get_LTC6946_SPI_FIELD
  For SPI FIELDS
  - reads specific address locations
  - identifies and returns specific field in question
    - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
--------------------------------------------------------------------------- */
long get_LTC6946_SPI_FIELD(uint8_t cs, uint8_t f) {
 
return LTC6946_read_field(cs, LTC6946_spi_map[f][ADDRx], LTC6946_spi_map[f][DxMSB], LTC6946_spi_map[f][NUMBITS]);
}
 
/* -------------------------------------------------------------------------
  FUNCTION: LTC6946_write
  - writes 8 bit Data field to LTC6946.
  - has to shift data by one bit to account for RW bit
--------------------------------------------------------------------------- */
void LTC6946_write(uint8_t cs, uint8_t address, uint8_t Data) {
LT_union_int16_2bytes rx;
  
address=address << 1; // shift to left to account for R/W bit
spi_transfer_word(cs, (address<<8) | Data, &rx.LT_uint16);
}


 /* -------------------------------------------------------------------------
  FUNCTION: LTC6946_write_field
  For SPI FIELDS
  - reads specific address location
  - identifies and returns specific field in question
    - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
---------------------------------------------------------------------------- */
uint8_t LTC6946_write_field(uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits){
long current_content, desired_content, reg_val;
int LSB_loc, i, j, num_reg, bit_shift;
long temp_arr[32];
  
for(i=0; i<32 ; i++) temp_arr[i]=0;   // init temp_arr
  
// read data in current address location and put in a bit array
num_reg=0;
current_content=0;
do {
   bit_shift=(MSB_loc+1)-(numbits-num_reg*8);
   current_content=LTC6946_read(cs, (address+num_reg)) + (current_content<<8);

   num_reg++;
} while((bit_shift<0) && (num_reg<4));
for(i=0; i<(8*num_reg); i++) {temp_arr[i]=(current_content>>i) & 1; }
  
// exchange current bits with desired bits
LSB_loc = 8*(num_reg-1)+MSB_loc-numbits+1;
for(i=LSB_loc, j=0; i<=(MSB_loc+(num_reg-1)*8); i++, j++){
   temp_arr[i] = (field_data>>j) &1;
   } // end of for loop
    
// reconstruct bits into an integer
desired_content = 0;
for(i=0; i<(8*num_reg); i++) {
   desired_content = desired_content | (temp_arr[i]<> 8*(num_reg-1-i)) & 0xff;
   LTC6946_write(cs, (address+i), reg_val);
   } // end of for loop
} // end of LTC6946_write_field
 
 
/* -------------------------------------------------------------------------
   FUNCTION: get_LTC6946_REGSIZE
   - returns # of addresses in parts register map (array size)
---------------------------------------------------------------------------- */
uint8_t get_LTC6946_REGSIZE(){
return sizeof(LTC6946_reg);
}
 
 
/* -------------------------------------------------------------------------
   FUNCTION: get_LTC6946_SPI_FIELD_NUMBITS
   - returns the number of bits for a given field name in the SPI map
---------------------------------------------------------------------------- */
uint8_t get_LTC6946_SPI_FIELD_NUMBITS(uint8_t f) {
return LTC6946_spi_map[f][NUMBITS];
}
 
 
/* -------------------------------------------------------------------------
   FUNCTION: get_LTC6946_SPI_FIELD_RW
   - returns if the given field name is (0)read/write or (1)read_only field
---------------------------------------------------------------------------- */
uint8_t get_LTC6946_SPI_FIELD_RW(uint8_t f) {
return LTC6946_spi_map[f][R_ONLY];
}
 
 
/* -------------------------------------------------------------------------
   FUNCTION: set_LTC6946_SPI_FIELD
   For SPI FIELDS 
   - reads specific address location
   - identifies and returns specific field in question
   - can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
---------------------------------------------------------------------------- */
void set_LTC6946_SPI_FIELD(uint8_t cs, uint8_t f, long field_data) {
LTC6946_write_field(cs, field_data, LTC6946_spi_map[f][ADDRx], LTC6946_spi_map[f][DxMSB], LTC6946_spi_map[f][NUMBITS]);
}
 

/* -------------------------------------------------------------------------
   FUNCTION: set_LTC6946_ALLREGS
   - writes data to all registers at once
--------------------------------------------------------------------------- */
void set_LTC6946_ALLREGS(uint8_t cs, uint8_t reg01, uint8_t reg02, uint8_t reg03, uint8_t reg04, uint8_t reg05, uint8_t reg06, uint8_t reg07, uint8_t reg08, uint8_t reg09, uint8_t reg0A) {
uint8_t i;
 
LTC6946_reg[1] = reg01;
LTC6946_reg[2] = reg02;
LTC6946_reg[3] = reg03;
LTC6946_reg[4] = reg04;
LTC6946_reg[5] = reg05;
LTC6946_reg[6] = reg06; 
LTC6946_reg[7] = reg07;
LTC6946_reg[8] = reg08;
LTC6946_reg[9] = reg09;
LTC6946_reg[10] = reg0A;
   
for(i=1; i<11; i++)  LTC6946_write(cs, i, LTC6946_reg[i]);
} // end of set_LTC6946_ALLREGS
 
 
/* -------------------------------------------------------------------------
   FUNCTION: LTC6946_init
   - initializes the SPI MAP
   - for ease of programming there is spreadsheet that automates this some.
----------------------------------------------------------------------------*/
void LTC6946_init() { 
   
// spi map    
LTC6946_spi_map[LTC6946_ALCCAL][ADDRx]=0x07;   LTC6946_spi_map[LTC6946_ALCCAL][DxMSB]= 5;   LTC6946_spi_map[LTC6946_ALCCAL][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ALCEN][ADDRx]=0x07;    LTC6946_spi_map[LTC6946_ALCEN][DxMSB]= 7;    LTC6946_spi_map[LTC6946_ALCEN][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ALCHI][ADDRx]=0x00;    LTC6946_spi_map[LTC6946_ALCHI][DxMSB]= 4;    LTC6946_spi_map[LTC6946_ALCHI][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ALCLO][ADDRx]=0x00;    LTC6946_spi_map[LTC6946_ALCLO][DxMSB]= 3;    LTC6946_spi_map[LTC6946_ALCLO][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ALCMON][ADDRx]=0x07;   LTC6946_spi_map[LTC6946_ALCMON][DxMSB]= 6;   LTC6946_spi_map[LTC6946_ALCMON][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ALCULOK][ADDRx]=0x07;  LTC6946_spi_map[LTC6946_ALCULOK][DxMSB]= 4;  LTC6946_spi_map[LTC6946_ALCULOK][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_BD][ADDRx]=0x03;       LTC6946_spi_map[LTC6946_BD][DxMSB]= 7;       LTC6946_spi_map[LTC6946_BD][NUMBITS]= 4;
LTC6946_spi_map[LTC6946_BST][ADDRx]=0x08;      LTC6946_spi_map[LTC6946_BST][DxMSB]= 7;      LTC6946_spi_map[LTC6946_BST][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CAL][ADDRx]=0x07;      LTC6946_spi_map[LTC6946_CAL][DxMSB]= 1;      LTC6946_spi_map[LTC6946_CAL][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CP][ADDRx]=0x09;       LTC6946_spi_map[LTC6946_CP][DxMSB]= 3;       LTC6946_spi_map[LTC6946_CP][NUMBITS]= 4;
LTC6946_spi_map[LTC6946_CPCHI][ADDRx]=0x0a;    LTC6946_spi_map[LTC6946_CPCHI][DxMSB]= 7;    LTC6946_spi_map[LTC6946_CPCHI][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPCLO][ADDRx]=0x0a;    LTC6946_spi_map[LTC6946_CPCLO][DxMSB]= 6;    LTC6946_spi_map[LTC6946_CPCLO][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPDN][ADDRx]=0x0a;     LTC6946_spi_map[LTC6946_CPDN][DxMSB]= 0;     LTC6946_spi_map[LTC6946_CPDN][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPINV][ADDRx]=0x0a;    LTC6946_spi_map[LTC6946_CPINV][DxMSB]= 4;    LTC6946_spi_map[LTC6946_CPINV][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPMID][ADDRx]=0x0a;    LTC6946_spi_map[LTC6946_CPMID][DxMSB]= 5;    LTC6946_spi_map[LTC6946_CPMID][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPRST][ADDRx]=0x0a;    LTC6946_spi_map[LTC6946_CPRST][DxMSB]= 2;    LTC6946_spi_map[LTC6946_CPRST][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPUP][ADDRx]=0x0a;     LTC6946_spi_map[LTC6946_CPUP][DxMSB]= 1;     LTC6946_spi_map[LTC6946_CPUP][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_CPWIDE][ADDRx]=0x0a;   LTC6946_spi_map[LTC6946_CPWIDE][DxMSB]= 3;   LTC6946_spi_map[LTC6946_CPWIDE][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_FILT][ADDRx]=0x08;     LTC6946_spi_map[LTC6946_FILT][DxMSB]= 6;     LTC6946_spi_map[LTC6946_FILT][NUMBITS]= 2;
LTC6946_spi_map[LTC6946_LKCT][ADDRx]=0x09;     LTC6946_spi_map[LTC6946_LKCT][DxMSB]= 5;     LTC6946_spi_map[LTC6946_LKCT][NUMBITS]= 2;
LTC6946_spi_map[LTC6946_LKEN][ADDRx]=0x07;     LTC6946_spi_map[LTC6946_LKEN][DxMSB]= 0;     LTC6946_spi_map[LTC6946_LKEN][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_LKWIN][ADDRx]=0x09;    LTC6946_spi_map[LTC6946_LKWIN][DxMSB]= 7;    LTC6946_spi_map[LTC6946_LKWIN][NUMBITS]= 2;
LTC6946_spi_map[LTC6946_LOCK][ADDRx]=0x00;     LTC6946_spi_map[LTC6946_LOCK][DxMSB]= 2;     LTC6946_spi_map[LTC6946_LOCK][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_MTCAL][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_MTCAL][DxMSB]= 2;    LTC6946_spi_map[LTC6946_MTCAL][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_ND][ADDRx]=0x05;       LTC6946_spi_map[LTC6946_ND][DxMSB]= 7;       LTC6946_spi_map[LTC6946_ND][NUMBITS]= 16;
LTC6946_spi_map[LTC6946_OD][ADDRx]=0x08;       LTC6946_spi_map[LTC6946_OD][DxMSB]= 2;       LTC6946_spi_map[LTC6946_OD][NUMBITS]= 3;
LTC6946_spi_map[LTC6946_OMUTE][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_OMUTE][DxMSB]= 1;    LTC6946_spi_map[LTC6946_OMUTE][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_PART][ADDRx]=0x0b;     LTC6946_spi_map[LTC6946_PART][DxMSB]= 4;     LTC6946_spi_map[LTC6946_PART][NUMBITS]= 5;
LTC6946_spi_map[LTC6946_PDALL][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_PDALL][DxMSB]= 7;    LTC6946_spi_map[LTC6946_PDALL][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_PDOUT][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_PDOUT][DxMSB]= 4;    LTC6946_spi_map[LTC6946_PDOUT][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_PDPLL][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_PDPLL][DxMSB]= 6;    LTC6946_spi_map[LTC6946_PDPLL][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_PDREFO][ADDRx]=0x02;   LTC6946_spi_map[LTC6946_PDREFO][DxMSB]= 3;   LTC6946_spi_map[LTC6946_PDREFO][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_PDVCO][ADDRx]=0x02;    LTC6946_spi_map[LTC6946_PDVCO][DxMSB]= 5;    LTC6946_spi_map[LTC6946_PDVCO][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_POR][ADDRx]=0x02;      LTC6946_spi_map[LTC6946_POR][DxMSB]= 0;      LTC6946_spi_map[LTC6946_POR][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_RD][ADDRx]=0x03;       LTC6946_spi_map[LTC6946_RD][DxMSB]= 1;       LTC6946_spi_map[LTC6946_RD][NUMBITS]= 10;
LTC6946_spi_map[LTC6946_REV][ADDRx]=0x0b;      LTC6946_spi_map[LTC6946_REV][DxMSB]= 7;      LTC6946_spi_map[LTC6946_REV][NUMBITS]= 3;
LTC6946_spi_map[LTC6946_RFO][ADDRx]=0x08;      LTC6946_spi_map[LTC6946_RFO][DxMSB]= 4;      LTC6946_spi_map[LTC6946_RFO][NUMBITS]= 2;
LTC6946_spi_map[LTC6946_THI][ADDRx]=0x00;      LTC6946_spi_map[LTC6946_THI][DxMSB]= 1;      LTC6946_spi_map[LTC6946_THI][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_TLO][ADDRx]=0x00;      LTC6946_spi_map[LTC6946_TLO][DxMSB]= 0;      LTC6946_spi_map[LTC6946_TLO][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_UNLOK][ADDRx]=0x00;    LTC6946_spi_map[LTC6946_UNLOK][DxMSB]= 5;    LTC6946_spi_map[LTC6946_UNLOK][NUMBITS]= 1;
LTC6946_spi_map[LTC6946_x][ADDRx]=0x01;        LTC6946_spi_map[LTC6946_x][DxMSB]= 5;        LTC6946_spi_map[LTC6946_x][NUMBITS]= 6;
  
LTC6946_spi_map[LTC6946_ALCCAL][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_ALCEN][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_ALCHI][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_ALCLO][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_ALCMON][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_ALCULOK][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_BD][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_BST][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CAL][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CP][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPCHI][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPCLO][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPDN][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPINV][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPMID][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPRST][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPUP][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_CPWIDE][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_FILT][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_LKCT][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_LKEN][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_LKWIN][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_LOCK][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_MTCAL][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_ND][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_OD][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_OMUTE][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_PART][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_PDALL][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_PDOUT][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_PDPLL][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_PDREFO][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_PDVCO][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_POR][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_RD][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_REV][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_RFO][R_ONLY]= 0;
LTC6946_spi_map[LTC6946_THI][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_TLO][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_UNLOK][R_ONLY]= 1;
LTC6946_spi_map[LTC6946_x][R_ONLY]= 0;


} // end of LTC6946_init

void set_LTC6946_global_fref(unsigned long fref_MHz, unsigned long fref_Hz){
LTC6946_Fref_MHz=fref_MHz;
LTC6946_Fref_Hz=fref_Hz;
}

void set_LTC6946_global_frf(unsigned long frf_MHz, unsigned long frf_Hz){
LTC6946_Frf_MHz=frf_MHz;
LTC6946_Frf_Hz=frf_Hz;
}

unsigned long get_LTC6946_global_fref_MHz(){
return LTC6946_Fref_MHz;
}

unsigned long get_LTC6946_global_fref_Hz(){
return LTC6946_Fref_Hz;
}

unsigned long get_LTC6946_global_frf_MHz(){
return LTC6946_Frf_MHz;
}

unsigned long get_LTC6946_global_frf_Hz(){
return LTC6946_Frf_Hz;
}


/* -------------------------------------------------------------------------
   FUNCTION: calc_odiv
   - calculates the output divider setting based on the frf and version of LTC6946
   - @return odiv = 1-6 for valid setting, 999 as invalid frequency
---------------------------------------------------------------------------- */  
unsigned long LTC6946_calc_odiv(char part_version[], unsigned long frf[2]){
unsigned long odiv, max_fout, min_fout, temp_val,i, temp_out;
unsigned long max_fout64[2];
unsigned long min_fout64[2];
unsigned long temp_fout[2];
unsigned long temp_i[2];
boolean valid_input=false;

// Determine which frequency range to verify too based on part version 
if (part_version[8]=='1') {  // if this is a LTC6946-1 
    max_fout=LTC6946_1_MAXFREQ;
    min_fout=LTC6946_1_MINFREQ;
    }
else if (part_version[8]=='2') { // if this is a LTC6946-2
    max_fout=LTC6946_2_MAXFREQ;
    min_fout=LTC6946_2_MINFREQ;
    }
else if (part_version[8]=='3') { // if this is a LTC6946-3
    max_fout=LTC6946_3_MAXFREQ;
    min_fout=LTC6946_3_MINFREQ;
    }
else if (part_version[8]=='4') { // if this is a LTC6946-4
    max_fout=LTC6946_4_MAXFREQ;
    min_fout=LTC6946_4_MINFREQ; 
    }
else {
    Serial.print("No default Frequencies for this board:  ");
    Serial.println(part_version);
    }  // end if-then-else statement
HZto64(max_fout64,max_fout,0L);
HZto64(min_fout64,min_fout,0L);
  
// verify desired frequency falls within a divider range (1-6)  
valid_input=false;
for(i=1; i<=6; i++) {
   init64(temp_i,0L,i);
   temp_fout[0] = frf[0];
   temp_fout[1] = frf[1];
   mul64(temp_fout,temp_i);
   if (lt64(temp_fout,max_fout64) || eq64(temp_fout, max_fout64)) {  // same as frf*i <= max_fout
      if (lt64(min_fout64,temp_fout) || eq64(temp_fout, min_fout64)) {// same as frf*i >= min_fout
         valid_input=true;
         odiv=i;
         }
      }
   } // end of for loop
 
if (valid_input == false) odiv= 999L;
return odiv;

} // end of LTC6946_calc_odiv

/* -------------------------------------------------------------------------
   FUNCTION: LTC6946_set_frf
   Calculates the integer (N) and output divider (OD) SPI values
   using self created 64bit math functions.
   
  Datasheet equations
    fvco = fpfd*N
    frf  = fvco/O
    fpfd = fref/R
    
    can be modified to the following equations
    N   = (int) (fvco/fpfd)  = (int) frf*O*R/fref
    
    where
    N = ndiv, O= odiv,  in the code below
    
    Linduino One (Arduino Uno) is limited to 32 bit floats/double/long.
    32 bit math functions will create rounding errors with the above equations, 
    tha can result in frequency errors.
    Therefore, the following code uses self created 64bit functions for 64bit integer math.
    
    - frf (33 bits) LTC6946 max frf/fvco = 6.0GHZ, which is 23 bit number (2^33 = 8.59G)
    - fref (23 bits) LTC6946 min fref = 10MHz, which is a 23 bit number (2^23 = 8.3M)
    - O   (3 bits)
    - R   (10 bits)
    
    step 1: create 64 bit frf and fref numbers
    
    step 2: calculate O (output divider)
    
    step 3: get current R-divider setting
    
    step 4: calculate frf*O*R
               max bit count/resolution: 33b+3b+10b= 46b
    step 5: calculate N(16b), using value from step 1
    - N = (int) frf*O*R/fref
    - max bit count/resolution: 46b-23b = 13b
---------------------------------------------------------------------------- */
void LTC6946_set_frf(char part_version[]){
unsigned long frf_MHz, frf_Hz, fref_MHz, fref_Hz, odiv, rdiv, ndiv, N_remainder, temp_val;
unsigned long N64[2], R64[2], O64[2], temp_long[2];
char buffer[100];
unsigned long frf[2], frf_act[2];
unsigned long fref[2];
unsigned long temp_math[2];
unsigned long frf_rdiv_odiv[2];
unsigned long frf_rdiv_odiv_int[2];
unsigned long roundup[2];
uint8_t regval;
uint8_t address;          
uint8_t tx1;
uint8_t tx2;
uint8_t tx3;
uint8_t tx4;
uint8_t tx5;
uint8_t *rx;
/* step 1: create 64 bit frf and fref numbers
   32 bit xxxx MHz number and 32 bit yyy yyy Hz number. */
frf_MHz=LTC6946_Frf_MHz;
frf_Hz=LTC6946_Frf_Hz;
HZto64(frf, frf_MHz, frf_Hz);

fref_MHz=LTC6946_Fref_MHz;
fref_Hz=LTC6946_Fref_Hz;
HZto64(fref,fref_MHz,fref_Hz);

// step 2: calculate O (output divider)
odiv=LTC6946_calc_odiv(part_version,frf);

// step 3: get current R-divider setting
#if 1
rdiv=get_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_RD);    // reads selected field
#endif


// step 4: calculate frf*O*R
frf_rdiv_odiv[0]=0;
frf_rdiv_odiv[1]=odiv*rdiv;
mul64(frf_rdiv_odiv, frf);  // odiv*rdiv*frf
frf_rdiv_odiv_int[0]=frf_rdiv_odiv[0];  // copy odiv*rdiv*frf to another variable
frf_rdiv_odiv_int[1]=frf_rdiv_odiv[1];

// step 5: calculate N(16b), using value from step 3; N = (int) frf*O*R/fref
temp_math[0]=fref[0];   // copy fref to temp variable for math operation
temp_math[1]=fref[1];
div64(frf_rdiv_odiv_int, temp_math);   // frf_rdiv_odiv_int= [(frf*odiv*rdiv)]/fref  -->  int(fvco/fpfd)
ndiv=frf_rdiv_odiv_int[1]; 

// step 6: find N for closest frequency - accounts for rounding with integer math
temp_math[0]=fref[0];   // copy fref to temp variable for math operation
temp_math[1]=fref[1];
shl64by(frf_rdiv_odiv,13);            // frf_rdiv_odiv     -->  [(frf*odiv*rdiv)<<13]/fref = N(double) <<13
div64(frf_rdiv_odiv,temp_math);
shl64by(frf_rdiv_odiv_int,13); // frf_rdiv_odiv_int  -->  [(int)((frf*odiv*rdiv)/fref)] <<13 = N(int) <<13 
sub64(frf_rdiv_odiv,frf_rdiv_odiv_int);  // N(double) <<13 - N(int)<<13

// at this point frf_rdiv_odiv is the delta between N(double) and N(int) shifted by 13 bits.
// if this remainder is < 4096, N(int) will give the closest frequency
// if this remainder is >=4096, N(int)+1 will give the closest frequency
// 4096 is mid point of the 13 bit number range
N_remainder = (frf_rdiv_odiv[1] & 8191L);  // 13 bits max code = 8191
if(N_remainder >= 4096) {
  ndiv=ndiv+1; 
  }


// program part and print out results to screen
set_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_OD,odiv);    // programs output divider
Serial.print("OD = ");
Serial.println(odiv);

Serial.print("RD = ");
Serial.println(rdiv);

Serial.print(F("ND = "));
Serial.println(ndiv);
#if 1
/* ------------single byte transfer method ---------------- */
set_LTC6946_SPI_FIELD(LTC6946_CS,LTC6946_ND,ndiv);    // programs N-divider

// calibrate the part
address = 0x07;
regval = 0x63;  // sets ALCMON=1, ALCCAL=1, LKEN=1 and CAL=1
LTC6946_write(LTC6946_CS, address, regval);
#endif

#if 0
/* ------------multi byte transfer method ---------------- */
tx1=5<<1; // shift 1 bit to account for write bit=0
tx2=(0xff00 & ndiv)>>8;
tx3=(0xff & ndiv);
tx4=0x63;
tx5 = LTC6946_read(LTC6946_CS,8);
Serial.print(F("tx1 = "));
Serial.println(tx1);
Serial.print(F("tx2 = "));
Serial.println(tx2);
Serial.print(F("tx3 = "));
Serial.println(tx3);
Serial.print(F("tx4 = "));
Serial.println(tx4);
Serial.print(F("tx5 = "));
Serial.println(tx5);
temp_val = read_int();  //! Reads the user command
 output_low(QUIKEVAL_CS);                  //! 1) Pull CS low
 *rx = SPI.transfer(tx1);             //! 2) Read byte and send byte
 *rx = SPI.transfer(tx2);             //! 2) Read byte and send byte
 *rx = SPI.transfer(tx3);             //! 2) Read byte and send byte
 *rx = SPI.transfer(tx4);             //! 2) Read byte and send byte
 *rx = SPI.transfer(tx5);             //! 2) Read byte and send byte
 output_high(QUIKEVAL_CS);                 //! 3) Pull CS high
#endif

/////  calculate actual fout here and print out
frf_act[0]=fref[0];
frf_act[1]=fref[1];
N64[0]=0; R64[0]=0; O64[0]=0;
N64[1]=ndiv;
R64[1]=rdiv;
O64[1]=odiv;

mul64(frf_act,N64);  // N*fref 
div64(frf_act,R64);  // N*fref/rdiv (or N*fpfd) 
div64(frf_act,O64);  // N*fpdf/odiv
if(frf_act[0]==0) {  // no 32 bit overflow case
   Serial.print(F("Actual Output Frequency (closest available) is "));
   Serial.print(frf_act[1]);
   Serial.println("Hz");
   }
else {  // overflow case
   temp_math[0]=frf_act[0];
   temp_math[1]=frf_act[1];
   temp_long[0]=0;
   temp_long[1]=OneMHz;
   div64(temp_math,temp_long);  // frf/1e6
   Serial.print(F("Actual Output Frequency (closest available) is "));
   Serial.print(temp_math[1]);
   Serial.print("MHz + ");
   temp_long[0]=0;
   temp_long[1]=OneMHz;
   mul64(temp_math,temp_long);  // int(frf/1e6)*1e6
   sub64(frf_act,temp_math);    //  frf-int(frf/1e6)*1e6
   Serial.print(frf_act[1]);
   Serial.println("Hz");
   }
}


/* -------------------------------------------------------------------------
   FUNCTION: prt
   Prints HEX representation of 64 bit an
---------------------------------------------------------------------------- */
void prt(unsigned long  an[]){
  Serial.print(an[0],HEX);
  Serial.print(" ");
 Serial.println(an[1],HEX);
}


/* -------------------------------------------------------------------------
   FUNCTION: init64
   Creates a equivalent 64 bit number from 2 32 bit numbers
    an[0]=bigPart    //upper 32 bits
    an[1]=littlePart //lower 32 bits
---------------------------------------------------------------------------- */
void init64(unsigned long  an[], unsigned long bigPart, unsigned long littlePart ){
  an[0]=bigPart;
  an[1]=littlePart;
}

/* -------------------------------------------------------------------------
   FUNCTION: HZto64
   create a 64 bit Hz number from
   32 bit xxxx MHz number and 32 bit yyy yyy Hz number.
   A) if an < 2^32 bits 
      an(upper 32b) = 0
      an(lower 32b) = MHzPart(32b)*1MHz + HzPart (32b)
   B) if an > 2^32 bits (4,294,967,296) 
     an(upper 32b) = 1
     an(lower 32b) = ((MHzPart-4294)*1MHz+HzPart)-967296
---------------------------------------------------------------------------- */
void HZto64(unsigned long  an[], unsigned long MHzPart, unsigned long HzPart ){

if((MHzPart>4295) || ((MHzPart==4294) && (HzPart>=967296))){
  an[0]=1L;                                        // upper 32 bits 
  an[1] =(MHzPart-4294L)*OneMHz + HzPart-967296L;  // lower 32 bits
  }
else {
  an[0] = 0;                        // upper 32 bits
  an[1] = MHzPart*OneMHz+HzPart;    // lower 32 bits
  }
}

/* -------------------------------------------------------------------------
   FUNCTION: shl64
   Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1)
---------------------------------------------------------------------------- */
void shl64(unsigned long  an[]){
 an[0] <<= 1; 
 if(an[1] & 0x80000000)
   an[0]++; 
 an[1] <<= 1; 
}


/* -------------------------------------------------------------------------
   FUNCTION: shr64
   Single Bit shift right of equivalent 64 bit number (an[] = an[]>>1)
---------------------------------------------------------------------------- */
void shr64(unsigned long  an[]){
 an[1] >>= 1; 
 if(an[0] & 0x1)
   an[1]+=0x80000000; 
 an[0] >>= 1; 
}


/* -------------------------------------------------------------------------
   FUNCTION: shl64by
   Multi Bit shift left of equivalent 64 bit number (an[] = an[]<>shiftnum)
---------------------------------------------------------------------------- */
void shr64by(unsigned long  an[], uint8_t shiftnum){
uint8_t i;

for(i=0; i>= 1; 
   if(an[0] & 0x1)
      an[1]+=0x80000000; 
   an[0] >>= 1; 
   }
}


/* -------------------------------------------------------------------------
   FUNCTION: add64
   64 bit Add ann to an (an[] = an[] + ann[])
---------------------------------------------------------------------------- */
void add64(unsigned long  an[], unsigned long  ann[]){
  an[0]+=ann[0];
  if(an[1] + ann[1] < ann[1])
    an[0]++;
  an[1]+=ann[1];
}


/* -------------------------------------------------------------------------
   FUNCTION: sub64
   64 bit Subtract ann from an (an[] = an[] - ann[])
---------------------------------------------------------------------------- */
void sub64(unsigned long  an[], unsigned long  ann[]){
  an[0]-=ann[0];
  if(an[1] < ann[1]){
    an[0]--;
  }
  an[1]-= ann[1];
}


/* -------------------------------------------------------------------------
   FUNCTION: eq64
   64 bit, if an == ann, then true
---------------------------------------------------------------------------- */
boolean eq64(unsigned long  an[], unsigned long  ann[]){
  return (an[0]==ann[0]) && (an[1]==ann[1]);
}


/* -------------------------------------------------------------------------
   FUNCTION: lt64
   64 bit, if an < ann, then true
---------------------------------------------------------------------------- */
boolean lt64(unsigned long  an[], unsigned long  ann[]){
  if(an[0]>ann[0]) return false;
  return (an[0]

Download LTC6946 Linduino Header File

/*!
 LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO

@verbatim
 SPI DATA FORMAT (MSB First):

 Write Sequence:
       Byte #1                    Byte #2
 MOSI: A6 A5 A4 A3 A2 A1 A0 W   D7 D6 D5 D4 D3 D2 D1 D0
 MISO: X  X  X  X  X  X  X  X   X  X  X  X  X  X  X  X

 Read Sequence:
       Byte #1                    Byte #2
 MOSI: A6 A5 A4 A3 A2 A1 A0 R   X  X  X  X  X  X  X  X
 MISO: X  X  X  X  X  X  X  X   D7 D6 D5 D4 D3 D2 D1 D0

 W    : SPI Write (0)
 R    : SPI Read  (1)
 Ax   : Address
 Dx   : Data Bits
 X    : Don't care

@endverbatim

http://www.linear.com/product/LTC6946

http://www.linear.com/product/LTC6946#demoboards

REVISION HISTORY
$Revision: 3018 $
$Date: 2014-12-01 15:53:20 -0800 (Mon, 01 Dec 2014) $

Copyright (c) 2013, Linear Technology Corp.(LTC)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Linear Technology Corp.

The Linear Technology Linduino is not affiliated with the official Arduino team.
However, the Linduino is only possible because of the Arduino team's commitment
to the open-source community.  Please, visit http://www.arduino.cc and
http://store.arduino.cc , and consider a purchase that will help fund their
ongoing work.
*/

/*! @file
    @ingroup LTC6946
    Header for LTC6946: Ultralow Noise and Spurious 0.37GHz to 6.39GHz IntegerN Synthesizer with Integrated VCO
*/

#ifndef LTC6946_H

#define LTC6946_H


//! Define the SPI CS pin
#ifndef LTC6946_CS
#define LTC6946_CS QUIKEVAL_CS  //! SPI Chip Select Pin
#endif


/*! @name LTC6946 Registers Fields in Alphabetical Order */
#define LTC6946_ALCCAL 1   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ALCEN 2   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ALCHI 3   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ALCLO 4   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ALCMON 5   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ALCULOK 6   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_BD 7   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_BST 8   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CAL 9   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CP 10   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPCHI 11   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPCLO 12   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPDN 13   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPINV 14   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPMID 15   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPRST 16   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPUP 17   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_CPWIDE 18   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_FILT 19   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_LKCT 20   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_LKEN 21   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_LKWIN 22   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_LOCK 23   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_MTCAL 24   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_ND 25   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_OD 26   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_OMUTE 27   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PART 28   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PDALL 29   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PDOUT 30   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PDPLL 31   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PDREFO 32   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_PDVCO 33   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_POR 34   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_RD 35   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_REV 36   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_RFO 37   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_THI 38   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_TLO 39   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_UNLOK 40   //!<  for spi_map array, defines location for field specific information used to create the spi map
#define LTC6946_x 41   //!<  for spi_map array, defines location for field specific information used to create the spi map


#define LTC6946_NUM_REGADDR 12  //!< Defines number of LTC6946 SPI registers, used in spi_map array
#define LTC6946_NUM_REGFIELD 41 //!< Defines number of LTC6946 SPI fields, used in spi_map array

#define ADDRx 0                 //!< used for 2nd dim of 2d spi_map array
#define DxMSB 1                 //!< used for 2nd dim of 2d spi_map array
#define NUMBITS 2               //!< used for 2nd dim of 2d spi_map array
#define R_ONLY 3                //!< used for 2nd dim of 2d spi_map array

#define OneMHz 1000000L         //!< 1MHz in long format, used in 64 bit math

#define LTC6946_1_MAXFREQ 3740  //!< LTC6946-1 upper freq limit
#define LTC6946_2_MAXFREQ 4910  //!< LTC6946-2 upper freq limit
#define LTC6946_3_MAXFREQ 5790  //!< LTC6946-3 upper freq limit
#define LTC6946_4_MAXFREQ 6390  //!< LTC6946-4 upper freq limit

#define LTC6946_1_MINFREQ 2240  //!< LTC6946-1 lower freq limit
#define LTC6946_2_MINFREQ 3080  //!< LTC6946-2 lower freq limit
#define LTC6946_3_MINFREQ 3840  //!< LTC6946-3 lower freq limit
#define LTC6946_4_MINFREQ 4200  //!< LTC6946-4 lower freq limit

#define LTC6946_MIN_REF_FREQ 10  //!< LTC6946 lower reference frequency limit
#define LTC6946_MAX_REF_FREQ 250 //!< LTC6946 upper reference frequency limit

//! @} */

/* ------------------------------------------------------------------------- */
//! LTC6946 Read Single Address
//!  reads 8 bit Data field to LTC6946.
//!  has to shift data by one bit to account for RW bit
//! @return data that was read from address
uint8_t LTC6946_read(uint8_t cs,    //!< Chip Select Pin
                     int8_t address //!< Register address for the LTC6946.
                    );

                    
/* ------------------------------------------------------------------------- */
//! LTC6946 Read Single Field
//! For SPI FIELDS located in 1 or multiple address locations
//!  reads specific address locations
//!  identifies and returns specific field in question
//!  can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
//! @return data that was read from field
 long LTC6946_read_field(uint8_t cs,       //!< Chip Select Pin
                         uint8_t address,  //!< Register address for the LTC6946.
                         uint8_t MSB_loc,  //!< MSB bit location of field
                         uint8_t numbits   //!< length of field (i.e. number of bits in field)                    
                        );
 
 
/* ------------------------------------------------------------------------- */
//! Gets the LTC6946 SPI field value
//! calls function LTC6946_read_field, which
//!  reads specific address locations
//!  identifies and returns specific field in question
//!  can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
//! @return data that was read from field
long get_LTC6946_SPI_FIELD(uint8_t cs,          //!< Chip Select Pin
                           uint8_t f            //!< SPI field number
                          );
        
        
/* ------------------------------------------------------------------------- */
//! LTC6946 Write Single Address
//!  writes 8 bit Data field to LTC6946.
//!  has to shift data by one bit to account for RW bit
//! @return void
void LTC6946_write(uint8_t cs,                  //!< Chip Select Pin
                   uint8_t address,             //!< Register address for the LTC6946.
                   uint8_t Data                 //!< 8-bit data to be written to register
                  );

                  
/* ------------------------------------------------------------------------- */
//! LTC6946 Write Single Field
//!  For SPI FIELDS in 1 or multiple address locations
//!  reads specific address/field location then writes to specific field
//!  can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
//! @return void
 uint8_t LTC6946_write_field(uint8_t cs,        //!< Chip Select Pin
                             long field_data,   //!< Value field value to be set to
                             uint8_t address,   //!< Register address for the LTC6946.
                             uint8_t MSB_loc,   //!< MSB bit location of field
                             uint8_t numbits   //!< length of field (i.e. number of bits in field)
                            );
 
 
/* ------------------------------------------------------------------------- */
//! Sets the LTC6946 SPI field value
//! calls function LTC6946_read_field, which
//!  reads specific address/field location then writes to specific field
//!  can handle SPI fields in multiple addresses, if MSB bit is in the lower number address
//! @return void
void set_LTC6946_SPI_FIELD(uint8_t cs,          //!< Chip Select Pin
                           uint8_t f,           //!< SPI field number
                           long field_data      //!< Value field value to be set to
                          );

                          
/* ------------------------------------------------------------------------- */
//! Writes values to ALL LTC6946 RW address
//! @return void
void set_LTC6946_ALLREGS(uint8_t cs,            //!< Chip Select Pin
                         uint8_t reg01,         //!< LTC6946 register 1
                         uint8_t reg02,         //!< LTC6946 register 2   
                         uint8_t reg03,         //!< LTC6946 register 3 
                         uint8_t reg04,         //!< LTC6946 register 4 
                         uint8_t reg05,         //!< LTC6946 register 5 
                         uint8_t reg06,         //!< LTC6946 register 6
                         uint8_t reg07,         //!< LTC6946 register 7
                         uint8_t reg08,         //!< LTC6946 register 8
                         uint8_t reg09,         //!< LTC6946 register 9
                         uint8_t reg0A          //!< LTC6946 register 10
                        );

/* ------------------------------------------------------------------------- */
//! Initializes the SPI MAP arrays
//! The values set in initialization are used all the LTC6946 SPI/WRITE and 
//! read functions (set_LTC6946_SPI_FIELD, get_LTC6946_SPI_FIELD,
//! LTC6946_read, LTC6946_write, etc, etc)
//! @return void
void LTC6946_init();


/* ------------------------------------------------------------------------- */
//! returns # of addresses in parts register map (array size)
//! @return # of addresses in parts register map
uint8_t get_LTC6946_REGSIZE();


/* ------------------------------------------------------------------------- */
//! returns the number of bits for a given field name in the SPI map
//! @return the number of bits for a given field name in the SPI map
uint8_t get_LTC6946_SPI_FIELD_NUMBITS(uint8_t f //!< SPI field number 
                                      );

                                      
/* ------------------------------------------------------------------------- */
//! returns if the given field name is (0)read/write or (1)read_only field
//! @return if the given field is a (0)read/write or (1)read_only field
uint8_t get_LTC6946_SPI_FIELD_RW(uint8_t f   //!< SPI field number 
                                ) ; 

                                
/* ------------------------------------------------------------------------- */ 
//! calculates the output divider setting based on the frf and version of LTC6946
//! @return odiv = 1-6 divider setting for valid frequency, or 999 for invalid frequency
unsigned long LTC6946_calc_odiv(char part_version[],    //!< LTC6946 part number LTC6946-x
                                unsigned long frf[2]    //!< output frequency
                                );  

/* ------------------------------------------------------------------------- */ 
//! FUNCTION: LTC6946_set_frf
//!  Calculates the integer (N), fractional (NUM) and output divider (OD) SPI values
//!  using self created 64bit math functions.
//!   
//! Datasheet equations:
//! - fvco = fpfd*(N + F)
//! - frf  = fvco/O
//! - fpfd = fref/R
//!    
//!    can be modified to the following equations:
//!    - N   = (int) (fvco/fpfd)  = (int) frf*O*R/fref
//!    
//!    where:
//!    - N = ndiv, O= odiv  in the code below
//!    
//!    Linduino One (Arduino Uno) is limited to 32 bit floats/double/long.
//!    32 bit math functions will create rounding errors with the above equations, 
//!    that can result in frequency errors.
//!    Therefore, the following code uses self created 64bit functions for 64bit integer math.
//!    
//!    - frf (33 bits) LTC6946-4 max frf/fvco = 6.4GHZ, which is 33 bit number (2^33 = 8.59G)
//!    - fref (23 bits) LTC6946 min fref = 10MHz, which is a 23 bit number (2^23 = 8.3M)
//!    - O   (3 bits)
//!    - R   (10 bits)
//!    
//!    step 1: create 64 bit frf and fref numbers
//!    
//!    step 2: calculate O (output divider)
//!    
//!    step 3: get current R-divider setting
//!    
//!    step 4: calculate frf*O*R
//!               max bit count/resolution: 33b+3b+10b= 46b
//!
//!    step 5: calculate N(16b), using value from step 1
//!    - N = (int) frf*O*R/fref
//!    - max bit count/resolution: 46b-23b = 23b
//! @return void                            
void LTC6946_set_frf(char part_version[]  //!< LTC6946 part number LTC6946-x
                    );
        

/* ------------------------------------------------------------------------- */ 
//! sets globals LTC6946_Fref_MHz and LTC6946_Fref_Hz
//! @return void
void set_LTC6946_global_fref(unsigned long fref_MHz, unsigned long fref_Hz);


/* ------------------------------------------------------------------------- */ 
//! sets globals LTC6946_Frf_MHz and LTC6946_Frf_Hz
//! @return void
void set_LTC6946_global_frf(unsigned long frf_MHz, unsigned long frf_Hz);


/* ------------------------------------------------------------------------- */ 
//! returns global LTC6946_Fref_MHz 
//! @return LTC6946_Fref_MHz
unsigned long get_LTC6946_global_fref_MHz();


/* ------------------------------------------------------------------------- */ 
//! returns global LTC6946_Fref_Hz 
//! @return LTC6946_Fref_Hz
unsigned long get_LTC6946_global_fref_Hz();


/* ------------------------------------------------------------------------- */ 
//! returns global LTC6946_Frf_MHz 
//! @return LTC6946_Frf_MHz
unsigned long get_LTC6946_global_frf_MHz();


/* ------------------------------------------------------------------------- */ 
//! returns global LTC6946_Frf_Hz 
//! @return LTC6946_Frf_Hz
unsigned long get_LTC6946_global_frf_Hz();

    
/* ------------------------------------------------------------------------- */                                
//!   create a 64 bit Hz number from
//!   32 bit xxxx MHz number and 32 bit yyy yyy Hz number.
//!   A) if an < 2^32 bits:
//!      - an(upper 32b) = 0;
//!      - an(lower 32b) = MHzPart(32b)*1MHz + HzPart (32b)
//!
//!   B) if an > 2^32 bits (4,294,967,296):
//!     - an(upper 32b) = 1
//!     - an(lower 32b) = ((MHzPart-4294)*1MHz+HzPart)-967296
//! @return void                                
void HZto64(unsigned long  an[],            //!< 64 bit number, 1x2 32 bit array
            unsigned long MHzPart,          //!< integer in MHZ 
            unsigned long HzPart            //!< integer in Hz                                
            );                            


/* ------------------------------------------------------------------------- */
//! Creates a equivalent 64 bit number from 2 32 bit numbers
//! - an[0]=bigPart    //upper 32 bits
//! - an[1]=littlePart //lower 32 bits
//! @return void
void init64(unsigned long an[],        //!< 64 bit number, 1x2 32 bit array
            unsigned long bigPart,     //!< upper 32 bits
            unsigned long littlePart   //!< lower 32 bits
           );

/* ------------------------------------------------------------------------- */
//! Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1)
//! @return void
void shl64(unsigned long  an[]         //!<  an[] = an[]<<1
          );

/* ------------------------------------------------------------------------- */
//! Multi Bit shift left of equivalent 64 bit number (an[] = an[]<>shiftnum
          );

/* ------------------------------------------------------------------------- */
//! Multi Bit shift right of equivalent 64 bit number (an[] = an[]>>shiftnum)
//! @return void
void shr64by(unsigned long  an[],     //!<  an[] = an[]>>shiftnum
             uint8_t shiftnum         //!<  number of bits to shift right
            );

/* ------------------------------------------------------------------------- */
//! 64 bit Add ann to an (an[] = an[] + ann[])
//! @return void
void add64(unsigned long  an[],      //!<  64 bit number, in 1x2 32bit array
           unsigned long  ann[]      //!<  64 bit number, in 1x2 32bit array
          );

/* ------------------------------------------------------------------------- */
//! 64 bit Subtract ann from an (an[] = an[] - ann[])
//! @return void
void sub64(unsigned long  an[],      //!<  64 bit number, in 1x2 32bit array
           unsigned long  ann[]      //!<  64 bit number, in 1x2 32bit array
          );

/* ------------------------------------------------------------------------- */
//! 64 bit, if an == ann, then true
//! @return true, if an==ann; false, if an<>ann
boolean eq64(unsigned long  an[],    //!<  64 bit number, in 1x2 32bit array
             unsigned long  ann[]    //!<  64 bit number, in 1x2 32bit array
            );

/* ------------------------------------------------------------------------- */
//! 64 bit, if an < ann, then true
//! @return true, if anann
boolean lt64(unsigned long  an[],     //!<  64 bit number, in 1x2 32bit array
             unsigned long  ann[]     //!<  64 bit number, in 1x2 32bit array
            );

/* ------------------------------------------------------------------------- */
//! 64 bit Divide,   num=num/div
//! @return void
void div64(unsigned long num[],    //!<  numerator: 64 bit number, in 1x2 32bit array
           unsigned long den[]     //!<  denominator: 64 bit number, in 1x2 32bit array
          );


/* ------------------------------------------------------------------------- */
//! 64 bit multiply,   an=an*ann
//! @return void
void mul64(unsigned long an[],     //!<  64 bit number, in 1x2 32bit array
           unsigned long ann[]     //!<  64 bit number, in 1x2 32bit array
          );
 
/* ------------------------------------------------------------------------- */
//! Prints HEX representation of 64 bit an
//! @return void 
void prt(unsigned long  an[]       //!<  64 bit number, in 1x2 32bit array
        ); 

#endif  // LTC6946_H

Technical Support