I'm trying to control an AD9834 eval board with an Arduino Nano, but I can't seem to get any of the commands I try to give it to go through. I've got pin 10 (SS) connected to FSYNC, pin 11 (MOSI) connected to SDATA, and pin 13 (SCK) connected to SCLK.
I've used the evaluation software to load values into the frequency register and I'm able to measure the output successfully using an oscilloscope. So far I'm just trying to apply a reset to get the board to turn off its output, and here's the code I'm using for that:
Serial.begin(9600); const int SS = 10; pinMode(SS, OUTPUT); SPI.begin(); // SPI setup section: SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0)); digitalWrite(SS, LOW); Serial.println("SS LOW"); //The control word is written in two bytes: SPI.transfer(0x21); // Byte 1: 0010 0001 SPI.transfer(0x00); // Byte 2: 0000 0000 Serial.println("First control word written"); digitalWrite(SS, HIGH); SPI.endTransaction();
By my understanding, that should set the reset bit high and turn off the output, but nothing happens when I actually run the code. Can anyone figure out where I'm going wrong?
When the reset bit is set to high, it resets the internal registers to 0 and this corresponds to an analog output of midscale.
SPi mode incorrect, SPI mode 3
I changed the SPI mode to SPI_MODE3, but it still doesn't change the output from the sine wave on the oscilloscope.
It's not even doing that though, when I set the reset to 1 the output remains a sine wave. I think my problem is that the Arduino's not getting it's information through to the AD board. Could the bitrate be causing a problem? I just picked an arbitrary value below the stated maximum of 40MHz for the AD board, is there a specific value that's usually used/best to use?
Upon looking at the SPISettings function a little more closely, it says to use the maximum speed listed for the device. I'm now doing that, but it's still not working.
Apologies for the delay, the question got missed in the email.
Did you fix the problem?
Can you share the data you are transferring to the device?
Did you reset the device before program it?