My AD_9833 doesn't work

I changed from int MSB: int LSB; int phase = 0; and nothing to do.
AD9933 doesn't work.
Other idea, runaway_pancake?

MSB = (int)((calculated_freq_word & 0xFFFC000) >> 14);
LSB = (int)(calculated_freq_word & 0x3FFF);

to

MSB = (uint16_t)((calculated_freq_word & 0xFFFC000) >> 14);
LSB = (uint16_t)(calculated_freq_word & 0x3FFF);

maybe?

Nothing to do. Why? It doesn't work with MSB = (uint16_t)((calculated_freq_word & 0xFFFC000) >> 14); LSB = (uint16_t)(calculated_freq_word & 0x3FFF);

Sorry. Sulimarco suggested the int/uint16_t dilemma (??)
and you replied that you didn't know how to implement that
so the "how to" was my contribution.
I know next to nothing about the Due.

Did you have any success bit-banging, instead of using hardware SPI?

There is any other HW solutions insted using SPI.h ?
For example #include <MD_AD9833.h> ?
I wait any HW and SW solutions.

They say the MD_AD9833 is compatible with all architectures.
I downloaded the library, the example is very basic looking.

// Basic MD_AD9833 test file
// Initialises the device to default conditions
// Connect a pot to A0 to change the frequency by turning the pot
#include <MD_AD9833.h>
#include <SPI.h>

// Pins for SPI comm with the AD9833 IC
#define DATA  11	///< SPI Data pin number
#define CLK   13	///< SPI Clock pin number
#define FSYNC 10	///< SPI Load pin number (FSYNC in AD9833 usage)

MD_AD9833	AD(FSYNC);  // Hardware SPI
// MD_AD9833	AD(DATA, CLK, FSYNC); // Arbitrary SPI pins

void setup(void)
{
	AD.begin();
}

void loop(void)
{
	static uint16_t lastv = 0;
	uint16_t v = analogRead(A0);
	if (abs(v-lastv) > 20)
	{
		AD.setFrequency(MD_AD9833::CHAN_0, 1000 + v);
		lastv = v;
	}
}

Does that not work?

This code must work also with the DUE but, as already stated, if we use the hw SPI, i.e. the following line is uncommented
MD_AD9833 AD(FSYNC); // Hardware SPI
SCLK is pin 3 of the SPI connector and MOSI is pin 4 of the SPI connector.

If we want to use different pins we have to uncomment the following line to enable the bit bang SPI:
MD_AD9833 AD(DATA, CLK, FSYNC); // Arbitrary SPI pins
and declare which pins we want to use.

I used and replace the follow code:

#include <MD_AD9833.h>
#include <SPI.h>

// Pins for SPI comm with the AD9833 IC
#define DATA  11  ///< SPI Data pin number
#define CLK   13  ///< SPI Clock pin number
#define FSYNC 10  ///< SPI Load pin number (FSYNC in AD9833 usage)

//MD_AD9833 AD(FSYNC);  // Hardware SPI
MD_AD9833  AD(DATA, CLK, FSYNC); // Arbitrary SPI pins

void setup(void)
{
  AD.begin();
}

void loop(void)
{
    AD.setFrequency(MD_AD9833::CHAN_0, 1000);
}

and that doesn't work. WHY???
I used PIN 10,11 and 13

Do you use a breakout board for the AD9833?
If yes, which model?
Can you post a picture of your setup?
How do you check that the AD9833 doesn’t work?
Do you have a scope to check the signals?

Yes i used the breakout board for the AD9833 model GY9833, GY9837.
I use the a digital oscilloscope than display always the same SIN WAVE 55Hz and not 1000Hz as the code.


Above the pfoto of my project and AD9833.

Maybe this is not the solution, but it cannot be good to have --

void loop(void)
{
    AD.setFrequency(MD_AD9833::CHAN_0, 1000);
}

where that instruction keeps looping (over and over and over).
It should be executed Once (not repeatedly, 'ad infinitum').
The easiest way to accomplish that would be to place it in setup (),
ergo --

#include <MD_AD9833.h>
#include <SPI.h>

// Pins for SPI comm with the AD9833 IC
#define DATA  11  ///< SPI Data pin number
#define CLK   13  ///< SPI Clock pin number
#define FSYNC 10  ///< SPI Load pin number (FSYNC in AD9833 usage)

//MD_AD9833 AD(FSYNC);  // Hardware SPI
MD_AD9833  AD(DATA, CLK, FSYNC); // Arbitrary SPI pins

void setup(void)
{
  AD.begin();

  AD.setFrequency(MD_AD9833::CHAN_0, 1000);
}

void loop(void)
{
}

And since you have an oscilloscope --
have you checked for activity on data, clk and fsync (10, 11, 13) ?
[Not at the Due - but at the breakout.]

Further check the output directly on the breakout output (without any capacitor), and see also this link.

Yes there are activity on data in 11,10 and 13.
Checked with the scope.

I used your code but it doesn't work. No signal output.

I have no more ideas other than thinking thar your breakout module is faulty …

A shot in the dark --
From your pic I see 'AGND' on the breakout is not connected.
Why not connect that to DGND?

I think it is connected inside the breakout board.
Can the op confirm this?