Hi, I am currently using your library for the ADF4351 chip with arduino uno. My ADF4351 board has a reference clock at 25 Mhz. I change the example code to generate 40 Mhz, Here is the main code file:
#include <Arduino.h>
#include "adf4351.h"
#define SWVERSION "1.0"
#define PIN_SS 9 ///< SPI slave select pin, default value
ADF4351 vfo(PIN_SS, SPI_MODE0, 1000000UL , MSBFIRST) ;
void setup()
{
Serial.begin(9600) ;
Serial.print("Hello adf4351 demo v") ;
Serial.println(SWVERSION) ;
Wire.begin() ;
/*!
setup the chip (for a 10 mhz ref freq)
most of these are defaults
*/
vfo.pwrlevel = 0 ; ///< sets to -4 dBm output
vfo.RD2refdouble = 0 ; ///< ref doubler off
vfo.RD1Rdiv2 = 0 ; ///< ref divider off
vfo.ClkDiv = 150 ;
vfo.BandSelClock = 80 ;
vfo.RCounter = 1 ; ///< R counter to 1 (no division)
vfo.ChanStep = steps[4] ; ///< set to 100 kHz steps
/*!
sets the reference frequency to 10 Mhz
*/
if ( vfo.setrf(25000000UL) == 0 )
Serial.println("ref freq set to 10 Mhz") ;
else
Serial.println("ref freq set error") ;
/*!
initialize the chip
*/
vfo.init() ;
/*!
enable frequency output
*/
vfo.enable() ;
}
void loop()
{
/*!
do a set of freq changes (40 Mhz, 4 GHz, and 1Ghz, )
*/
vfo.disable();
delay(2000);
Serial.println("setf() to 40 MHz") ;
if ( vfo.setf(40000000UL) == 0 ) {
Serial.print("setf() success freq:") ;
Serial.println(vfo.cfreq) ;
} else {
Serial.println("setf() error") ;
}
vfo.enable();
Serial.print("PLL INT:");
Serial.println(vfo.N_Int);
Serial.print("PLL FRAC:");
Serial.println(vfo.Frac);
Serial.print("PLL MOD:");
Serial.println(vfo.Mod);
Serial.print("PLL PFD:");
Serial.println(vfo.PFDFreq);
Serial.print("PLL output divider:");
Serial.println(vfo.outdiv);
Serial.print("PLL prescaler:");
Serial.println(vfo.Prescaler);
Serial.println("");
delay(2000);
}
I get this error:
setf() to 40 MHz
output freq diff than requested
Mod out of range
setf() error
cfreq: 22349
PLL INT:0
PLL FRAC:-23
PLL MOD:2147483246
PLL PFD:25000000.00
PLL output divider:64
PLL prescaler:0
It is weird because I also try to use Analog software to calculate, and it calculates that INT is 102, FRAC is 2, PFD is 25 Mhz, Div is 64.
I look at the code but still don't understand why it cannot calculate the right value like the software.
Hi, I am currently using your library for the ADF4351 chip with arduino uno. My ADF4351 board has a reference clock at 25 Mhz. I change the example code to generate 40 Mhz, Here is the main code file:
I get this error:
It is weird because I also try to use Analog software to calculate, and it calculates that INT is 102, FRAC is 2, PFD is 25 Mhz, Div is 64.
I look at the code but still don't understand why it cannot calculate the right value like the software.