// ******************************************** HARDWARE IMPORTANT******************************************************** // With an Arduino UN0/Nano : uses a potential divider to reduce the voltage: // // MOSI (pin D11) to ADF DATA // SCK (pin D13) to ADF CLK // Select (PIN D10)to ADF LE // // Potential divider 560 Ohm with 1000 Ohm to ground on Arduino pins 11, 13 and 3 to adapt from 5V // to 3.3V the digital signals DATA, CLK and LE from the Arduino. // // Ideally use a 3V3 Arduino board like a DUE or Zero - on these boards use the 6 pin SPI connector // // ******************************************** HARDWARE IMPORTANT******************************************************** #include #define ADF5355_CS 10 // datasheet suggests 50MHz max for clock speed // here its set at 10MHz which seems lightning fast SPISettings MySettings(10000000, MSBFIRST, SPI_MODE0); // pre-calculated register values from Andy 'JNTs software for 500MHz with 100MHz clock //uint32_t registers[13] = {0x00200280, 0x00000001, 0x0001FFF2, 0x00000003, 0x3000A584, 0x00800025, 0x15602076, 0x120000E7, 0x102D0428, 0x2A29FCC9, 0x00C0193A, 0x0061300B, 0x0001041C}; // 1GHz with 100MHz clock // //uint32_t registers[13] = {0x00200280, 0x00000001, 0x00001F42, 0x00000003, 0x3000A584, 0x00800025, 0x154FC476, 0x120000E7, 0x102D0428, 0x2A29FCC9, 0x00C0193A, 0x0061300B, 0x0001041C}; // 1.234GHz with 100MHz clock //uint32_t registers[13] = {0x00200310, 0x05C28F51, 0x00040012, 0x00000003, 0x3000A584, 0x00800025, 0x15402076, 0x120000E7, 0x102D0428, 0x2A29FCC9, 0x00C0193A, 0x0061300B, 0x0001041C}; // datasheet worked example 2112 MHz with reference 61.44 * 2) = 122.88 MHz //uint32_t registers[13] = {0x200220, 0x6000001, 0xC002, 0x3, 0x3000A784, 0x800025, 0x15220476, 0x120000E7, 0x102D0428, 0x302FCC9, 0xC03FFA, 0x61300B, 0x1041C}; // 2112 MHz with reference 100 MHz uint32_t registers[13] = {0x2002A0, 0x3D70A31, 0x6901F42, 0x3, 0x3000A784, 0x800025, 0x15220476, 0x120000E7, 0x102D0428, 0x302FCC9, 0xC01F7A, 0x61300B, 0x1041C}; void WriteReg32(const uint32_t value) { // send the data a byte at a time over SPI for (int i = 3; i >= 0; i--) // loop round 4 x 8 bits MSB first SPI.transfer((value >> 8 * i) & 0xFF); // offset, byte mask and send via SPI // // datasheet says 20ns minimum between HIGH and LOW below // clock of the Load Enable line to move the data from // the data register into the programing register set by the bottom 4 bits // digitalWrite(ADF5355_CS, HIGH); delayMicroseconds(1); digitalWrite(ADF5355_CS, LOW); } void SetADF5355() // bung the data into the ADF5355 { // Start the SPI transaction SPI.beginTransaction(MySettings); // active low load enable digitalWrite(ADF5355_CS, LOW); // send the 13 registers for (int i = 12; i >= 0; i--) WriteReg32(registers[i]); // de-select the SPI device digitalWrite(ADF5355_CS, HIGH); SPI.endTransaction(); } void setup() { pinMode(ADF5355_CS, OUTPUT); // Setup pins digitalWrite(ADF5355_CS, HIGH); SPI.begin(); // Init SPI bus } void loop() { delay (2000); // // send the registers every 2 seconds // not necessary once working, but useful // if you have a logic analysermabob attached // SetADF5355(); }