Alright I'm about at my wits end, I'm playing around with a AD9833 to synthasize a sin wave. I have combed though all forms of forums regarding the AD9833 to no avail. This is the circuit I'm running.
EDIT: although the circuit says Fsync is controlled by PB0(pin 53) its actually connected to pin 36 as per the code
Another EDIT: Im doing this on a breadboard, which as I have read is a big no no, could this damage the part, or would it only introduce crazy interference. . I'm controlling the AD9833 with an Arduino Mega2560 and communicating with the SPI protocol, but instead of using the SS pin on the Arduino I'm manually controlling the Fsync pin, as I need to transfer 16bit.
// the sensor communicates using SPI, so include the library:
#include <SPI.h>
// pins used for the connection with the sensor
// the other you need are controlled by the SPI library):
const int fSync = 36;
void setup() {
Serial.begin(9600);
// start the SPI library:
SPI.begin();
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
// initalize the data ready and chip select pins:
delay(10);
pinMode(fSync, OUTPUT);
digitalWrite(fSync, HIGH);
delay(10);
digitalWrite(fSync, LOW);
SPI.transfer(0x20); //turns B28 - write 28bits to FREQ register
SPI.transfer(0x00);
digitalWrite(fSync, HIGH);
delayMicroseconds(1);
digitalWrite(fSync, LOW);
SPI.transfer(0x4C); //write 0x0C0F to 14LSB
SPI.transfer(0x0F);
digitalWrite(fSync, HIGH);
delayMicroseconds(1);
digitalWrite(fSync, LOW);
SPI.transfer(0x70); //write 0x30FF to 14MSB
SPI.transfer(0xFF);
digitalWrite(fSync, HIGH);
delayMicroseconds(1);
digitalWrite(fSync, LOW);
SPI.transfer(0x00); //Output sinewave
SPI.transfer(0x00);
digitalWrite(fSync, HIGH);
delayMicroseconds(1);
SPI.end();
}
void loop() {
}
The data is being clock in on the falling edge, and the clock is idling high.
This is 1MHz signal I'm using as my master clock, and its coming from a function generator.
This monstrosity is what I'm getting for an output. By my calculations the FREQ register should have 0x30FFC0F = 51.379E6. This means the output frequency should be about 191 kHz - which is a fluke I think becasue this wave form has a frequency of about 200 kHz
I'm sure the data registers are being updated as can be seen here when I enter the following SPI data
0x2000
0x4C00
0x7F0F
0x0000
I have checked my voltages and everything seems to be withing range
- CAP/2.5V is ~2.49V
- AGND to DGND 0V
- VDD 4.95V from the arduino
My only thought is that I fried the chip when I soldered it to the breakout board, I have tried 2 already and am hesitant to put the 3rd on in as these bad boys are not cheap.
Are there any glaring issue that anyone can see? Ask for any other data if needed.