// ******************************************** 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 D3) 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. // // Arduino pin 2 (for lock detection) directly connected to ADF4351 card MUXOUT. // ******************************************** HARDWARE IMPORTANT******************************************************** // ***************************************************************************** // // // register values for a 1966.5 MHz output // // 10MHz clock: 0xC48018,0x8008051,0x4E42,0x4B3,0x95003C,0x58005 // // 25MHz clock: 0x4E8040,0x80080C9,0x4E42,0x4B3,0x9C803C,0x58005 // // Copy these values into the array declaration on the line below // // for 1968 MHz use: // // 10MHz clock: 0xC48018,0x8008029,0x4E42,0x4B3,0x95003C,0x580005 // // 25MHz clock: 0x4E8058,0x80080C9,0x4E42,0x4B3,0x9C803C,0x580005 // // 100MHz // // 10 Mhz clock: 0xA00000, 0x8008011, 0x4E42, 0x4B3, 0xD5003C, 0x580005 // // 500MHz: // // 10 Mhz clock: 0xC80000, 0x8008011, 0x4E42, 0x4B3, 0xB5003C, 0x580005 // // 1000MHz: // // 10 Mhz clock: 0xC80000, 0x8008321, 0x4E42, 0x4B3, 0xA503FC, 0x580005 // // ****************************************************************************** // #include #define ADF4351_CS 7 SPISettings MySettings (10000000, MSBFIRST, SPI_MODE0); uint32_t registers[6] = {0xA00000, 0x8008011, 0x18004E42, 0x4B3, 0xD502FC, 0x580005}; void WriteReg32(const uint32_t value) { digitalWrite(ADF4351_CS, LOW); for (int i = 3; i >= 0; i--) // loop round 4 x 8 bits SPI.transfer((value >> 8 * i) & 0xFF); // offset, byte mask and send via SPI digitalWrite(ADF4351_CS, HIGH); delayMicroseconds(200); digitalWrite(ADF4351_CS, LOW); } void SetADF4351() // bung the data into the ADF4351 { SPI.beginTransaction(MySettings); for (int i = 5; i >= 0; i--) WriteReg32(registers[i]); SPI.endTransaction(); } void setup() { pinMode(ADF4351_CS, OUTPUT); // Setup pins digitalWrite(ADF4351_CS, HIGH); pinMode(LED_BUILTIN, OUTPUT); // using as a power light! digitalWrite(LED_BUILTIN, HIGH); SPI.begin(); // Init SPI bus } void loop() { delay (2000); SetADF4351(); }