Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board

Library for LTC6948: Ultralow Noise and Spurious 0.37GHz to 6.39GHz FracN Synthesizer with Integrated VCO. More...

Detailed Description

Library for LTC6948: Ultralow Noise and Spurious 0.37GHz to 6.39GHz FracN Synthesizer with Integrated VCO.

Definition in file LTC6948.cpp.

Go to the source code of this file.

Functions

uint8_t LTC6948_read (uint8_t cs, int8_t address)
 LTC6948 Read Single Address reads 8 bit Data field to LTC6948. More...
 
long LTC6948_read_field (uint8_t cs, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
 LTC6948 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. More...
 
long get_LTC6948_SPI_FIELD (uint8_t cs, uint8_t f)
 Gets the LTC6948 SPI field value calls function LTC6948_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. More...
 
void LTC6948_write (uint8_t cs, uint8_t address, uint8_t Data)
 LTC6948 Write Single Address writes 8 bit Data field to LTC6948. More...
 
uint8_t LTC6948_write_field (uint8_t cs, long field_data, uint8_t address, uint8_t MSB_loc, uint8_t numbits)
 LTC6948 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. More...
 
uint8_t get_LTC6948_REGSIZE ()
 returns # of addresses in parts register map (array size) More...
 
uint8_t get_LTC6948_SPI_FIELD_NUMBITS (uint8_t f)
 returns the number of bits for a given field name in the SPI map More...
 
uint8_t get_LTC6948_SPI_FIELD_RW (uint8_t f)
 returns if the given field name is (0)read/write or (1)read_only field More...
 
void set_LTC6948_SPI_FIELD (uint8_t cs, uint8_t f, long field_data)
 Sets the LTC6948 SPI field value calls function LTC6948_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. More...
 
void set_LTC6948_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 reg0B, uint8_t reg0C, uint8_t reg0D)
 Writes values to ALL LTC6948 RW address. More...
 
void LTC6948_init ()
 Initializes the SPI MAP arrays The values set in initialization are used all the LTC6948 SPI/WRITE and read functions (set_LTC6948_SPI_FIELD, get_LTC6948_SPI_FIELD, LTC6948_read, LTC6948_write, etc, etc) More...
 
void set_LTC6948_global_fref (unsigned long fref_MHz, unsigned long fref_Hz)
 sets globals LTC6948_Fref_MHz and LTC6948_Fref_Hz More...
 
void set_LTC6948_global_frf (unsigned long frf_MHz, unsigned long frf_Hz)
 sets globals LTC6948_Frf_MHz and LTC6948_Frf_Hz More...
 
unsigned long get_LTC6948_global_fref_MHz ()
 returns global LTC6948_Fref_MHz More...
 
unsigned long get_LTC6948_global_fref_Hz ()
 returns global LTC6948_Fref_Hz More...
 
unsigned long get_LTC6948_global_frf_MHz ()
 returns global LTC6948_Frf_MHz More...
 
unsigned long get_LTC6948_global_frf_Hz ()
 returns global LTC6948_Frf_Hz More...
 
unsigned long LTC6948_calc_odiv (char part_version[], unsigned long frf[2])
 calculates the output divider setting based on the frf and version of LTC6948 More...
 
void LTC6948_set_frf (char part_version[])
 FUNCTION: LTC6948_set_frf Calculates the integer (N), fractional (NUM) and output divider (OD) SPI values using self created 64bit math functions. More...
 
void prt (unsigned long an[])
 Prints HEX representation of 64 bit an. More...
 
void init64 (unsigned long an[], unsigned long bigPart, unsigned long littlePart)
 Creates a equivalent 64 bit number from 2 32 bit numbers. More...
 
void HZto64 (unsigned long an[], unsigned long MHzPart, unsigned long HzPart)
 create a 64 bit Hz number from 32 bit xxxx MHz number and 32 bit yyy yyy Hz number. More...
 
void shl64 (unsigned long an[])
 Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1) More...
 
void shr64 (unsigned long an[])
 Single Bit shift right of equivalent 64 bit number (an[] = an[]<<1) More...
 
void shl64by (unsigned long an[], uint8_t shiftnum)
 Multi Bit shift left of equivalent 64 bit number (an[] = an[]<<shiftnum) More...
 
void shr64by (unsigned long an[], uint8_t shiftnum)
 Multi Bit shift right of equivalent 64 bit number (an[] = an[]>>shiftnum) More...
 
void add64 (unsigned long an[], unsigned long ann[])
 64 bit Add ann to an (an[] = an[] + ann[]) More...
 
void sub64 (unsigned long an[], unsigned long ann[])
 64 bit Subtract ann from an (an[] = an[] - ann[]) More...
 
boolean eq64 (unsigned long an[], unsigned long ann[])
 64 bit, if an == ann, then true More...
 
boolean lt64 (unsigned long an[], unsigned long ann[])
 64 bit, if an < ann, then true More...
 
void div64 (unsigned long num[], unsigned long den[])
 64 bit Divide, num=num/div More...
 
void mul64 (unsigned long an[], unsigned long ann[])
 64 bit multiply, an=an*ann More...
 

Variables

uint8_t LTC6948_reg [LTC6948_NUM_REGADDR]
 number of LTC6948 spi addresses More...
 
uint8_t LTC6948_spi_map [(LTC6948_NUM_REGFIELD+1)][4]
 LTC6948 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability. More...
 
unsigned long LTC6948_Fref_MHz = 100
 Default Fref frequency - MHz portion (xxx); Fref = xxx, yyy,yyy. More...
 
unsigned long LTC6948_Fref_Hz = 0
 Default Fref frequency - Hz portion (yyy,yyy); Fref = x,xxx, yyy,yyy. More...
 
unsigned long LTC6948_Frf_MHz = 907
 Default Frf frequency - MHz portion (xxxx); Frf = x,xxx, yyy,yyy. More...
 
unsigned long LTC6948_Frf_Hz = 0
 Default Frf frequency - Hz portion (yyy,yyy); Frf = x,xxx, yyy,yyy. More...
 
unsigned long zero64 [] = {0,0}
 for 64bit math functions More...
 

Function Documentation

◆ add64()

void add64 ( unsigned long  an[],
unsigned long  ann[] 
)

64 bit Add ann to an (an[] = an[] + ann[])

Returns
void
Parameters
an64 bit number, in 1x2 32bit array
ann64 bit number, in 1x2 32bit array

Definition at line 917 of file LTC6948.cpp.

◆ div64()

void div64 ( unsigned long  num[],
unsigned long  den[] 
)

64 bit Divide, num=num/div

Returns
void
Parameters
numnumerator: 64 bit number, in 1x2 32bit array
dendenominator: 64 bit number, in 1x2 32bit array

Definition at line 966 of file LTC6948.cpp.

◆ eq64()

boolean eq64 ( unsigned long  an[],
unsigned long  ann[] 
)

64 bit, if an == ann, then true

Returns
true, if an==ann; false, if an<>ann
Parameters
an64 bit number, in 1x2 32bit array
ann64 bit number, in 1x2 32bit array

Definition at line 945 of file LTC6948.cpp.

◆ get_LTC6948_global_fref_Hz()

unsigned long get_LTC6948_global_fref_Hz ( )

returns global LTC6948_Fref_Hz

Returns
LTC6948_Fref_Hz

Definition at line 524 of file LTC6948.cpp.

◆ get_LTC6948_global_fref_MHz()

unsigned long get_LTC6948_global_fref_MHz ( )

returns global LTC6948_Fref_MHz

Returns
LTC6948_Fref_MHz

Definition at line 519 of file LTC6948.cpp.

◆ get_LTC6948_global_frf_Hz()

unsigned long get_LTC6948_global_frf_Hz ( )

returns global LTC6948_Frf_Hz

Returns
LTC6948_Frf_Hz

Definition at line 534 of file LTC6948.cpp.

◆ get_LTC6948_global_frf_MHz()

unsigned long get_LTC6948_global_frf_MHz ( )

returns global LTC6948_Frf_MHz

Returns
LTC6948_Frf_MHz

Definition at line 529 of file LTC6948.cpp.

◆ get_LTC6948_REGSIZE()

uint8_t get_LTC6948_REGSIZE ( )

returns # of addresses in parts register map (array size)

Returns
# of addresses in parts register map

Definition at line 229 of file LTC6948.cpp.

◆ get_LTC6948_SPI_FIELD()

long get_LTC6948_SPI_FIELD ( uint8_t  cs,
uint8_t  f 
)

Gets the LTC6948 SPI field value calls function LTC6948_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.

Returns
data that was read from field
Parameters
csChip Select Pin
fSPI field number

Definition at line 151 of file LTC6948.cpp.

◆ get_LTC6948_SPI_FIELD_NUMBITS()

uint8_t get_LTC6948_SPI_FIELD_NUMBITS ( uint8_t  f)

returns the number of bits for a given field name in the SPI map

Returns
the number of bits for a given field name in the SPI map
Parameters
fSPI field number

Definition at line 239 of file LTC6948.cpp.

◆ get_LTC6948_SPI_FIELD_RW()

uint8_t get_LTC6948_SPI_FIELD_RW ( uint8_t  f)

returns if the given field name is (0)read/write or (1)read_only field

Returns
if the given field is a (0)read/write or (1)read_only field
Parameters
fSPI field number

Definition at line 249 of file LTC6948.cpp.

◆ HZto64()

void HZto64 ( unsigned long  an[],
unsigned long  MHzPart,
unsigned long  HzPart 
)

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
    Returns
    void
Parameters
an64 bit number, 1x2 32 bit array
MHzPartinteger in MHZ
HzPartinteger in Hz

Definition at line 836 of file LTC6948.cpp.

◆ init64()

void init64 ( unsigned long  an[],
unsigned long  bigPart,
unsigned long  littlePart 
)

Creates a equivalent 64 bit number from 2 32 bit numbers.

  • an[0]=bigPart upper 32 bits
  • an[1]=littlePart lower 32 bits
    Returns
    void
Parameters
an64 bit number, 1x2 32 bit array
bigPartupper 32 bits
littlePartlower 32 bits

Definition at line 819 of file LTC6948.cpp.

◆ lt64()

boolean lt64 ( unsigned long  an[],
unsigned long  ann[] 
)

64 bit, if an < ann, then true

Returns
true, if an<ann; false, if an=>ann
Parameters
an64 bit number, in 1x2 32bit array
ann64 bit number, in 1x2 32bit array

Definition at line 955 of file LTC6948.cpp.

◆ LTC6948_calc_odiv()

unsigned long LTC6948_calc_odiv ( char  part_version[],
unsigned long  frf[2] 
)

calculates the output divider setting based on the frf and version of LTC6948

Returns
odiv = 1-6 divider setting for valid frequency, or 999 for invalid frequency
Parameters
part_versionLTC6948 part number LTC6948-x
frfoutput frequency

Definition at line 545 of file LTC6948.cpp.

◆ LTC6948_init()

void LTC6948_init ( )

Initializes the SPI MAP arrays The values set in initialization are used all the LTC6948 SPI/WRITE and read functions (set_LTC6948_SPI_FIELD, get_LTC6948_SPI_FIELD, LTC6948_read, LTC6948_write, etc, etc)

Returns
void

Definition at line 299 of file LTC6948.cpp.

◆ LTC6948_read()

uint8_t LTC6948_read ( uint8_t  cs,
int8_t  address 
)

LTC6948 Read Single Address reads 8 bit Data field to LTC6948.

has to shift data by one bit to account for RW bit

Returns
data that was read from address
Parameters
csChip Select Pin
addressRegister address for the LTC6948.

Definition at line 95 of file LTC6948.cpp.

◆ LTC6948_read_field()

long LTC6948_read_field ( uint8_t  cs,
uint8_t  address,
uint8_t  MSB_loc,
uint8_t  numbits 
)

LTC6948 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.

Returns
data that was read from field
Parameters
csChip Select Pin
addressRegister address for the LTC6948.
MSB_locMSB bit location of field
numbitslength of field (i.e. number of bits in field)

Definition at line 115 of file LTC6948.cpp.

◆ LTC6948_set_frf()

void LTC6948_set_frf ( char  part_version[])

FUNCTION: LTC6948_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

    • F=NUM/2^18 = NUM/262144

    can be modified to the following equations:

    • N = (int) (fvco/fpfd) = (int) frf*O*R/fref
    • NUM = (int) [262144 * (frf*O*R/fref -N)]

    where:

    • N = ndiv, O= odiv, NUM=fracN_num 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) LTC6948-4 max frf/fvco = 6.4GHZ, which is 33 bit number (2^33 = 8.59G)
    • fref (23 bits) LTC6948 min fref = 10MHz, which is a 23 bit number (2^23 = 8.3M)
    • O (3 bits)
  • R (5 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+5b= 41b

    step 5: calculate N(10b), using value from step 1 N = (int) frf*O*R/fref max bit count/resolution: 41b-23b = 18b

    step 6: calculate NUM (18b)

  • NUM = (int) [262144 * (frf*O*R/fref -N)]
  • NUM = (int) [2^18 * (frf*O*R/fref -N)]

    to get the correct value the above calculation are performed like this

  • NUM =((int)((frf*O*R/fref)<<23) - N<<23 + rounding) >> 5, where << & >> are bit shift left, right
  • note 1: << 23b was chosen, because step one use 41b, 41b +23b = 64b (max number for 64 bit math)
    • note 2: >> 5 was chosen because 23-5 = 2^18, which is the same as multiplying by 262144
    • note 3: the rounding variable is equivalent to adding 0.5 to the NUM number. the integer operation always rounds down, so adding a 0.5 to the number before rounding down ensures the closest value is selected. In this function the lower 5 bits of (frf*O*R/fref)<<23) - N<<23 (possible variable 0-31) are check to see if they are >=16. If they are then 16 is added to this number before performing the int and >>5 functions.
      Returns
      void
Parameters
part_versionLTC6948 part number LTC6948-x

Definition at line 659 of file LTC6948.cpp.

◆ LTC6948_write()

void LTC6948_write ( uint8_t  cs,
uint8_t  address,
uint8_t  Data 
)

LTC6948 Write Single Address writes 8 bit Data field to LTC6948.

has to shift data by one bit to account for RW bit

Returns
void
Parameters
csChip Select Pin
addressRegister address for the LTC6948.
Data8-bit data to be written to register

Definition at line 162 of file LTC6948.cpp.

◆ LTC6948_write_field()

uint8_t LTC6948_write_field ( uint8_t  cs,
long  field_data,
uint8_t  address,
uint8_t  MSB_loc,
uint8_t  numbits 
)

LTC6948 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.

Returns
void
Parameters
csChip Select Pin
field_dataValue field value to be set to
addressRegister address for the LTC6948.
MSB_locMSB bit location of field
numbitslength of field (i.e. number of bits in field)

Definition at line 178 of file LTC6948.cpp.

◆ mul64()

void mul64 ( unsigned long  an[],
unsigned long  ann[] 
)

64 bit multiply, an=an*ann

Returns
void
Parameters
an64 bit number, in 1x2 32bit array
ann64 bit number, in 1x2 32bit array

Definition at line 1013 of file LTC6948.cpp.

◆ prt()

void prt ( unsigned long  an[])

Prints HEX representation of 64 bit an.

Returns
void
Parameters
an64 bit number, in 1x2 32bit array

Definition at line 805 of file LTC6948.cpp.

◆ set_LTC6948_ALLREGS()

void set_LTC6948_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  reg0B,
uint8_t  reg0C,
uint8_t  reg0D 
)

Writes values to ALL LTC6948 RW address.

Returns
void
Parameters
csChip Select Pin
reg01LTC6948 register 1
reg02LTC6948 register 2
reg03LTC6948 register 3
reg04LTC6948 register 4
reg05LTC6948 register 5
reg06LTC6948 register 6
reg07LTC6948 register 7
reg08LTC6948 register 8
reg09LTC6948 register 9
reg0ALTC6948 register 10
reg0BLTC6948 register 11
reg0CLTC6948 register 12
reg0DLTC6948 register 13

Definition at line 272 of file LTC6948.cpp.

◆ set_LTC6948_global_fref()

void set_LTC6948_global_fref ( unsigned long  fref_MHz,
unsigned long  fref_Hz 
)

sets globals LTC6948_Fref_MHz and LTC6948_Fref_Hz

Returns
void

Definition at line 507 of file LTC6948.cpp.

◆ set_LTC6948_global_frf()

void set_LTC6948_global_frf ( unsigned long  frf_MHz,
unsigned long  frf_Hz 
)

sets globals LTC6948_Frf_MHz and LTC6948_Frf_Hz

Returns
void

Definition at line 513 of file LTC6948.cpp.

◆ set_LTC6948_SPI_FIELD()

void set_LTC6948_SPI_FIELD ( uint8_t  cs,
uint8_t  f,
long  field_data 
)

Sets the LTC6948 SPI field value calls function LTC6948_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.

Returns
void
Parameters
csChip Select Pin
fSPI field number
field_dataValue field value to be set to

Definition at line 262 of file LTC6948.cpp.

◆ shl64()

void shl64 ( unsigned long  an[])

Single Bit shift left of equivalent 64 bit number (an[] = an[]<<1)

Returns
void
Parameters
anan[] = an[]<<1

Definition at line 855 of file LTC6948.cpp.

◆ shl64by()

void shl64by ( unsigned long  an[],
uint8_t  shiftnum 
)

Multi Bit shift left of equivalent 64 bit number (an[] = an[]<<shiftnum)

Returns
void
Parameters
anan[] = an[]<<shiftnum
shiftnumnumber of bits to shift left

Definition at line 881 of file LTC6948.cpp.

◆ shr64()

void shr64 ( unsigned long  an[])

Single Bit shift right of equivalent 64 bit number (an[] = an[]<<1)

Returns
void
Parameters
anan[] = an[]>>shiftnum

Definition at line 868 of file LTC6948.cpp.

◆ shr64by()

void shr64by ( unsigned long  an[],
uint8_t  shiftnum 
)

Multi Bit shift right of equivalent 64 bit number (an[] = an[]>>shiftnum)

Returns
void
Parameters
anan[] = an[]>>shiftnum
shiftnumnumber of bits to shift right

Definition at line 899 of file LTC6948.cpp.

◆ sub64()

void sub64 ( unsigned long  an[],
unsigned long  ann[] 
)

64 bit Subtract ann from an (an[] = an[] - ann[])

Returns
void
Parameters
an64 bit number, in 1x2 32bit array
ann64 bit number, in 1x2 32bit array

Definition at line 930 of file LTC6948.cpp.

Variable Documentation

◆ LTC6948_Fref_Hz

unsigned long LTC6948_Fref_Hz = 0

Default Fref frequency - Hz portion (yyy,yyy); Fref = x,xxx, yyy,yyy.

Definition at line 84 of file LTC6948.cpp.

◆ LTC6948_Fref_MHz

unsigned long LTC6948_Fref_MHz = 100

Default Fref frequency - MHz portion (xxx); Fref = xxx, yyy,yyy.

Definition at line 83 of file LTC6948.cpp.

◆ LTC6948_Frf_Hz

unsigned long LTC6948_Frf_Hz = 0

Default Frf frequency - Hz portion (yyy,yyy); Frf = x,xxx, yyy,yyy.

Definition at line 86 of file LTC6948.cpp.

◆ LTC6948_Frf_MHz

unsigned long LTC6948_Frf_MHz = 907

Default Frf frequency - MHz portion (xxxx); Frf = x,xxx, yyy,yyy.

Definition at line 85 of file LTC6948.cpp.

◆ LTC6948_reg

uint8_t LTC6948_reg[LTC6948_NUM_REGADDR]

number of LTC6948 spi addresses

Definition at line 80 of file LTC6948.cpp.

◆ LTC6948_spi_map

uint8_t LTC6948_spi_map[(LTC6948_NUM_REGFIELD+1)][4]

LTC6948 spi map, stores MSB address location, MSB bit location, field length in bits, and R or RW capability.

Definition at line 81 of file LTC6948.cpp.

◆ zero64

unsigned long zero64[] = {0,0}

for 64bit math functions

Definition at line 88 of file LTC6948.cpp.