#include #include "common.h" // PB3 - ADF4350 LE // PB2 - SCK to ADF4350 CLK // PB1 - DO (MOSI) to ADF4350 DATA // PB0 - ADF4350 LD // PB4 - Status LED void Delay(uint32_t); uint8_t SendReceiveSPIData(uint8_t); void SendSPIDataADF4350 (uint32_t); int main() { // set instructions to configure the ADF4350 for a 1 GHz +5dBm output uint32_t ar0=0x500000; uint32_t ar1=0x8008011; uint32_t ar2=0x4e42; uint32_t ar3=0x4b3; uint32_t ar4=0xac803c; uint32_t ar5=0x580005; // alternative instructions for a 1001.25 MHz +5dBm output //uint32_t ar0=0x500008; //uint32_t ar1=0x8008029; //uint32_t ar2=0x4e42; //uint32_t ar3=0x4b3; //uint32_t ar4=0xac803c; //uint32_t ar5=0x580005; // set direction of PB1 (DO) and PB2 (USCK) as output DDRB=(1<> 24; uint8_t byte2 = (outval & 0x00FF0000) >> 16; uint8_t byte3 = (outval & 0x0000FF00) >> 8; uint8_t byte4 = outval & 0x000000FF; // send these to the ADF4350 via SPI SendReceiveSPIData (byte1); SendReceiveSPIData (byte2); SendReceiveSPIData (byte3); SendReceiveSPIData (byte4); // 2 x 16 version: // split into 2 x 16 bit words ///uint16_t highWord = (outval & 0xffff0000) >> 16; ///uint16_t lowWord = outval & 0x0000ffff; // send these to the ADF4350 via SPI ///SendReceiveSPIData (highWord); ///SendReceiveSPIData (lowWord); // delay so the clock has gone low before LE is taken high Delay(10); // pull LE high to load the data into the ADF4350 register PORTB |= (1 << PORTB3); // short delay while LE is high (minimum of 20ns) Delay(30); // pull LE low again PORTB &= ~(1 << PORTB3); }