AD9834 Module: No Triangle or Square wave outputs

Hello all. I am at the initial stages of trying to use an AD9834 module (china) with arduino.

So far, I have managed to write to the control register, frequency and phase register and get a decent sinusoidal output.

This module is also able to output triangle and square waves. But I have not been able to achieve either output yet.

1. Triangle Wave:
IAW the datasheet pg. 22, Table 18, I should get a triangle output when in the control register I have both:

  • The OPBITEN bit CLEARED.
  • The MODE bit SET.

2. Square Wave:

  • IAW the datasheet pg. 16, reads: "detector, it requires a minimum input frequency of typically 3 MHz."
  • IAW the datasheet pg. 22, Table 17, to output a square wave I need to have the bits set as either in line 2 or 3 or 5. I would expect a square wave pop-up from the SMA name "square".. Correct?

I have done all that, but I only get sinusoid from the 2 SMAs that are for sin and tri and I get nothing from the SMA that is named "square"..
Am i missing any elephants? Ideas?



/*******************
Connections:
SCLK  -> D13 (SCK)
SDATA -> D11 (MOSI)
*******************/

#include <SPI.h>

const int RST   = 8;
const int FSYN1 = 9;
const int FSYN2 = 10;

void setup() {

pinMode(RST,    OUTPUT);
pinMode(FSYN1,  OUTPUT);
pinMode(FSYN2,  OUTPUT);

digitalWrite(RST,   HIGH);
digitalWrite(FSYN1, HIGH);
digitalWrite(FSYN2, HIGH);

SPI.begin();
SPI.setDataMode(SPI_MODE2);
SPI.setBitOrder(MSBFIRST);

AD9834_RESET();
AD9834_FREQ();
AD9834_ENABLE();

delay(2000);

// Take AD9834 out of hardware reset.
digitalWrite(RST, LOW);
}

/* RESET: ----------------------------------------------------------------------------
Control Register write. Datasheeet recommends putting part in reset after power up. 
See Datasheet pg. 19, for details on Control Register write.*/

void AD9834_RESET()
{
digitalWrite(FSYN1, LOW);
SPI.transfer16(0b0010000100000010);
digitalWrite(FSYN1, HIGH);
}

/* FREQUENCY + PHASE: ---------------------------------------------------
FREQUENCY WORD: 
Is 28 bits, sent in two 14 bit parts LSB sent first. 
In both parts B15 and B16 address the frequency register.
01 -> FREQ0  |-------|  10 -> FREQ1
So, for FREQ1 the word should be 01xx xxxx xxxx xxxx for both parts. 
Where x are the 14 bits of the frequency word. 

PHASE WORD:
Is 12 bits. B14, B15 and B16 are set to 11 to address the phase register.
110 -> PHASE0
111 -> PHASE1
So, for PHASE0 the word should be 110x xxxx xxxx xxxx. B0 - B11 are the phase word and B12 is "don't care"
0xC000 sets a ZERO phase adjustment. */

void AD9834_FREQ()
{ 
//FREQUENCY
digitalWrite(FSYN1, LOW);
SPI.transfer16(0b0111010000001110);
SPI.transfer16(0b0100001101101001);

//PHASE
SPI.transfer(0b11000000);
SPI.transfer(0b00000000);             // 0b00000000 equals ZERO phase.
digitalWrite(FSYN1, HIGH);
Serial.println("FREQUENCY Done");
}

/* ENABLE: ----------------------------------------------------------------------------
Control Register write. Enable the AD9834 and set PIN/SW to 1. This enables Chip pin reset (hardware reset). 
The AD9834 will be left in a hardware reset state dcue to the HIGH on the RST pin. 
This is cleared at the end of the void setup().
To enable the PIN/SW pin, set control B9 to HIGH. */

void AD9834_ENABLE()
{ 
digitalWrite(FSYN1, LOW);
SPI.transfer(0x22);
SPI.transfer(0x00);
digitalWrite(FSYN1, HIGH);
}

void loop() {
}

Posting a link to the datasheet would give us more help.

1 Like

Of course.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.