//AD9850
DDS
test #define DDS_CLOCK 125000000 #define CLOCK 8 //pin connections for DDS #define LOAD 9 #define DATA 10 #define RESET 11 void setup() { pinMode (DATA, OUTPUT); pinMode (CLOCK, OUTPUT); pinMode (LOAD, OUTPUT); pinMode (RESET, OUTPUT); AD9850_init(); AD9850_reset(); SetFrequency(10000000); } void loop() { } void SetFrequency(unsigned long frequency) { unsigned long tuning_word = (frequency * pow(2, 32)) / DDS_CLOCK; digitalWrite (LOAD, LOW); shiftOut(DATA, CLOCK, LSBFIRST, tuning_word); shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 8); shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 16); shiftOut(DATA, CLOCK, LSBFIRST, tuning_word >> 24); shiftOut(DATA, CLOCK, LSBFIRST, 0x0); digitalWrite (LOAD, HIGH); } void AD9850_init() { digitalWrite(RESET, LOW); digitalWrite(CLOCK, LOW); digitalWrite(LOAD, LOW); digitalWrite(DATA, LOW); } void AD9850_reset() { //reset sequence is: // CLOCK & LOAD = LOW // Pulse RESET high for a few uS (use 5 uS here) // Pulse CLOCK high for a few uS (use 5 uS here) // Set DATA to ZERO and pulse LOAD for a few uS (use 5 uS here) // data sheet diagrams show only RESET and CLOCK being used to reset the device, but I see no output unless I also // toggle the LOAD line here. digitalWrite(CLOCK, LOW); digitalWrite(LOAD, LOW); digitalWrite(RESET, LOW); delay(5); digitalWrite(RESET, HIGH); //pulse RESET delay(5); digitalWrite(RESET, LOW); delay(5); digitalWrite(CLOCK, LOW); delay(5); digitalWrite(CLOCK, HIGH); //pulse CLOCK delay(5); digitalWrite(CLOCK, LOW); delay(5); digitalWrite(DATA, LOW); //make sure DATA pin is LOW digitalWrite(LOAD, LOW); delay(5); digitalWrite(LOAD, HIGH); //pulse LOAD delay(5); digitalWrite(LOAD, LOW); // Chip is RESET now } |