Operating AD5780 EVAL Board Via MicroController

OK, so thanks in advance because I am new here. I am reading the AD57XX drivers here  https://wiki.analog.com/resources/tools-software/uc-drivers/renesas/ad5780 and am struggling to understand how to get the device working and understanding it properly. I am using code here https://github.com/maxgerhardt/arduino-ad57xx-driver/blob/master/src/main.cpp in order to test the DAC. I have several questions about the drivers and operation in general. I will itemize them if that is ok

  1. Where in the drivers am I performing Slave Select and where am I determining Clock Speed? I have looked through the C in the drivers library, and it seems that each command, whether reading or writing selects the Slave/Master each time? I see no reference to which pins on my microcontroller it is reference though so I do not know if any of this is right.
  2. Why do I need to be reading in the Control Register or anything from the DAC at all? Why does this matter? All I want is to output a voltage
  3. How do I perform the right conversion to a voltage that I want? The command " AD57XX_SetDacValue() " takes a long, but I do not understand how that relates to a float value of voltage. Say I want 2.35 Volts, or a Sine Function from -2 to 2 Volts, how do I do this conversion?
  4. I don't know how to debug the system in general. When I run the example code, which is supposed to output a triangle wave function, I get a sin function. Is this just background noise that the DAC outputs. I don't know how to tweak parameters or understand it. If the photo is low resolution, from peak to anti peak, the wave function is only about 300 mV.

Thanks in advance for all the help.

  • 0
    •  Analog Employees 
    on Mar 25, 2019 11:06 AM over 1 year ago


    Someone's currently looking into this query and will respond to you as soon as possible.



  • Thanks Ivan, here I asked the question on StackExchange, so I answered 1 and 2. For 3, I suppose the drivers require me to convert from a float to the binary representation that the DAC requires, but I'm still confused by the best way to do this.

    I am also going to look around my department for a logical analyzer, but debugging advice would still be incredible. I'm surprised there's no guide to do something similar online yet

  • OK, let me upload pictures and explain what I have checked and let me know what I may be missing

    Here is my microcontroller. I have 6 pins attached. They are as follows

    Pin 6 - Blue- Ground

    Pin 7-Black- Ground

    Pin 10- Green -Slave Select

    Pin 11 - Red - MOSI

    Pin 12- Orange- MISO

    Pin 13-White- SCK

    Now, on the DAC, it is difficult to read the pin labels in the photo, but they are as follows






    SCLK- White

    This is correct right?

    I now have a 5 pin power supply. I am only using 4 pins. I have +5V and the COMM plugged into VCC and DGND respectively.

    I then have +12V attached to VDD, the same COMM attached to AGND and -12V attached to VSS. Is this correct?

    Finally,  ,  I have moved LK1 to Position B, and removed LK11. I have soldered a SDA pin to VOUT and attached it via a BNC cable, which I can measure on an oscilliscope across a 50Ohm resistor, pictured here.

    Then, this is the code I run

    #include <Arduino.h>
    #include <AD5780.h>
    void setup() {
      Serial.println("FIRMWARE STARTUP");
      /* same setup as in the RL78G13 driver example's Main.c */
        Serial.println("AD5780 OK");
        Serial.println("AD5780 Err");
      /* Resets the device to its power-on state. */
      /* Enables the DAC output. */
      /* The DAC register is set to use offset binary coding. */
       // Sets the value to which the DAC output is set when CLEAR is enabled.
      /* Performs a soft CLEAR operation. */
        /* Reads and displays the internal registers. */
         /* Read DAC. */
        long result = AD5780_GetRegisterValue(AD5780_REG_DAC,3);
        result = (result & 0xFFFFC) >> 2;
        Serial.print("DAC REG: ");
        Serial.println(result, HEX);
        /* Read Control. */
        result = AD5780_GetRegisterValue(AD5780_REG_CTRL,3);
        result = (result & 0x3E);  // Only Bits 5 through 1 are holding information.
        Serial.print("CTRL REG: ");
        Serial.println(result, HEX);
        /* Read ClearCode. */
        result = AD5780_GetRegisterValue(AD5780_REG_CLR_CODE,3);
        result = (result & 0xFFFFC) >> 2;
        Serial.print("CLEAR CODE: ");
        Serial.println(result, HEX);
    long dacVal  = 0;
    long step    = 0;
    long maxCode = 0x3FFFF;    // 18 bits
    long minCode = 0;
    void loop() {
      /* generate a triangle signal. 
      if(dacVal >= maxCode - step)
        step = -350;
      else if(dacVal <= minCode - step)
        step = 350;
      dacVal = 0x3FFFF;
      //50 microseconds is a very short amount of time
      //if pinMode() and digitalWrite() is used in the pin management layer,
      //these will take so long that 50uS is small in comparison..
    . Where might the error be? The code runs, and I have checked my wiring is correct.

  • 0
    •  Analog Employees 
    on Mar 28, 2019 1:47 AM over 1 year ago in reply to andrewkhardy

    Can you take a scope shot of the digital lines? SDIN, SCLK, SYNC, SDO.

    Also can you insert  link LK7 to pull it low, this would ensure that the data written is transferred from the input shift register to the DAC register ? I don't see that you are controlling the LDAC pin using your controller.

  • OK, yes you are right. I added a cable at Pin 5 to connect to LDAC. I am reading the Standalone Operation section (pg 19 of the AD5780 datasheet, not the evaluation board) more closely now.  I have also attached LK7, but it still does not provide me with a voltage output.

    static const int pinMapping[] = {
    		5, //GPIO1 (LDAC pin) is D7
    		8, //GPIO2 (CLR pin) is D8
    		9, //GPIO3 (RESET pin) is D9
    		10  //slave select (SYNC pin) 

    these are the setting in pinMgtLayer that I have changed now. If I was to have a changing voltage output, would I also need a CLR pin? In lieu of that I could also use the CTRL register instead? Would I then need to write to the CTRL register everytime I update the voltage, like?


    I am also attaching scope readings for the pins as follows: SDIN




    and finally my new LDAC pin

     Finally, is it necessary to have both DGND pins attached to my microcontroller? Would only 1 ground them?

  • 0
    •  Analog Employees 
    on Mar 29, 2019 2:12 AM over 1 year ago in reply to andrewkhardy

    You don't need to trigger the CLR and RESET pins every time you write on the AD5780.

    It seems different signals are coupling on your digital lines, if these are the actual signals then it definitely won't work.

    We would also recommend to shorten the connections of the digital lines to minimize parasitics that could affect the frame.

    Can you retake the scope shots and have all the digital lines on a single image? Also can you have the oscilloscope trigger on the SYNC falling edge pin.

    Single digital ground connection should be enough.

  • I do have a logic analyzer available to me, if we are at the point where the connections make sense, then I can upload images of that and try and diagnose? That will take me a moment to figure out, so let me know if there are any other suggestions, otherwise come Monday I will post logic analyzer photos.

Reply Children
  • 0
    •  Analog Employees 
    on Apr 2, 2019 1:52 AM over 1 year ago in reply to andrewkhardy

    Based on these scope shots, you are not sending 0x03, 0x3F 0xFF.

    For the AD5780, the data is valid on the falling edge of SCLK, so what you are actually writing on the part is 0x01 0x1F 0xFF. You are actually doing is doing a NOP (no operation) since your first 4 bits is "0000". See Table 7and Figure 2 on the data sheet.

    If you want to write on the DAC register, the first 4 bits should be "0001". For example you want to have a full scale output. the data you should send is 0x1F 0xFF 0xFC. Note that you have to pull the LDAC should be low.

    Refer to the SERIAL INTERFACE section on the data sheet for more details on how to write on the AD5780. Let us know if you have further questions.

  • Channel 3 is my MOSI and 4 is my CLK, how are you reading from this scope that I am not sending 0x03, 0x3F 0xFF ? That is what the SPI setting on the scope says I am sending out?

  • 0
    •  Analog Employees 
    on Apr 3, 2019 2:48 AM over 1 year ago in reply to andrewkhardy

    I'm looking at the falling edges of CLK and check if what is the level of MOSI at those times.

    Your scope interprets it at the rising edge of CLK, meanwhile the AD5780 reads it on the falling edge.

    The SPI mode that you are using is incorrect, You should be using SPI mode 1 or mode 2. You can refer to the following link for info regarding SPI modes.


  • I do nut understand that. The SPI modes are set in

    unsigned char AD5780_Init(void)
        SPI_Init(0, 1000000, 1, 0);

    where SPI_Init is defined as

    SPISettings spiSettings;
    unsigned char SPI_Init(unsigned char lsbFirst,
                           unsigned long clockFreq,
                           unsigned char clockPol,
                           unsigned char clockEdg)
        // Add your code here.
    	int spiMode = 1;
    	//decode modes according to https://www.arduino.cc/en/Reference/SPI
    	if(clockPol == 0) {
    		spiMode = clockEdg ? SPI_MODE1 : SPI_MODE0;
    	} else {
    		spiMode = clockEdg ? SPI_MODE3 : SPI_MODE2;
    	int bitOrder = lsbFirst ? LSBFIRST : MSBFIRST;
    	//modify SPI settings object used in transactions
    	spiSettings = SPISettings(clockFreq, bitOrder, spiMode);
    	//set slave-select pins to output
    	//this is used on the fly
    	return 1;

    which seems to me to mean I am defining CPOL = 1 and CPHA = 0, which is SPI Mode 2.  This is what I want is it not?