This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC8760: DAC8760

Part Number: DAC8760

Dear All,

        I have started working on An Project interfacing DAC8760 with Renesas R5F104.I have followed Some Reference Designs In which they have used an ISO7641 IC between the DAC8760 and Microcontroller..These are some query regading this

1.Do we Really require ISO7641 between them ??? 

  • Hi Firoz,

    A digital isolator is not required for communication between the DAC8760 and microcontroller. A digital isolator is used in applications where galvanic isolation is desired. Digital isolation can provide safety and protection as well as improved noise immunity.

    Thanks,

    Garrett

  • Hi Garret,

                 Thank you for reply and further i am proceding with the code.I have connected DAC8760 SPI lines directly with the Renesas Microcontroller.I have got an Library of DAC 8760 with MSP430 controller  Is ther any  Libraries avalable with Renesas..

    or an standard library with SPI read,write functions..

  • /*************************************************************************************************************************************************/
    /*!     DAC8760.c
     *
     *       This code is designed to perform standard command and control operations on the DAC8760 over a SPI bus. Functions exist to setup, configure
     *       and control the DAC8760.
     *
     *
     */
    /**************************************************************************************************************************************************
     *       Copyright � 2014 Texas Instruments Incorporated - http://www.ti.com/                                                                      *
     ***************************************************************************************************************************************************
     *  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
     *                                                                                                                                                 *
     *    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.                 *
     *                                                                                                                                                 *
     *    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the        *
     *    documentation and/or other materials provided with the distribution.                                                                         *
     *                                                                                                                                                 *
     *    Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived      *
     *    from this software without specific prior written permission.                                                                                *
     *                                                                                                                                                 *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          *
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     *
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         *
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    *
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE      *
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                                           *
     **************************************************************************************************************************************************/
    //
    //
    //   Thomas Schneider
    //   Texas Instruments Inc.
    //   July 2014
    //   Built with Code Composer Studio V6.0
    //***************************************************************************************************************************************************
    #include <stdint.h>
    #include <msp430.h>
    #include "DAC8760.h"
    #include "hal.h"
    
    static unsigned char RcvData[3];
    
    /*************************************************************************************************************************************************
     *  DAC8760_Write_Regs
     **************************************************************************************************************************************************/
    /*!
     * @brief Writes registers on the DAC8760.
     *
     * This function will execute a write register command to the DAC8760. This function can be used to update one register on the DAC8760.
     * No error checking is performed, so it is the user's responsibility to make sure they do not attempt to write past the end of the DAC8760 registers.
     *
     * @param[in]   writeValues    16 bit register value to place in the DAC8760
     * @param[in]   address        Address of the register to write
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_WriteReg (uint16_t writeValues, uint8_t address)
    {
        uint8_t outData[3];
    
        outData[0] = address;
    
        // Switch Endianess
        outData[1] = writeValues >> 8;
        outData[2] = writeValues & 0xff;
    
        DAC8760_SPIWrite (outData, RcvData);
    
    }
    
    /*************************************************************************************************************************************************
     *  DAC8760_Read_Regs
     **************************************************************************************************************************************************/
    /*!
     * @brief Reads registers on the DAC8760.
     *
     * This function will execute a read register command to the DAC8760 and return the resultant data. This function can be used to read one or more
     * registers from the DAC8760. No error checking is performed, so it is the user's responsibility to make sure they do not attempt to read past
     * the end of the DAC8760 registers.
     *
     * @param[out]   *readValues     Pointer to place the 8 bit register values from the DAC8760
     * @param[in]    address         Address of the register to read
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_ReadReg (uint8_t *readValues, uint8_t address)
    {
        uint8_t outData[3] = {0x55, 0x55, 0x55};
    
        // Sets the address for the read command
        outData[0] = DAC8760_READ_REGISTER;
        outData[2] = address;
        DAC8760_SPIWrite (outData, readValues);
    
        // Performs actual read of previous address
        outData[0] = DAC8760_WRITE_NOP_REGISTER;
        DAC8760_SPIWrite (outData, readValues);
    
    }
    
    /*************************************************************************************************************************************************
     *  Setup_DAC8760
     **************************************************************************************************************************************************/
    /*!
     * @brief Performs the setup of the DAC8760.
     *
     * This function will configure the DAC8760.
     *
     * @param[in]     controlReg             Value written into DAC8760_CONTROL_REGISTER
     * @param[in]     configurationReg       Value written into DAC8760_CONFIGURATION_REGISTER
     * @param[in]     gainCalReg             Value written into DAC8760_GAIN_CALIBRATION_REGISTER
     * @param[in]     zeroCalReg             Value written into DAC8760_ZERO_CALIBRATION_REGISTER
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_Setup (uint16_t controlReg, uint16_t configurationReg, uint16_t gainCalReg, uint16_t zeroCalReg)
    {
        DAC8760_SPISetupMaster();
        DAC8760_Reset();
        DAC8760_Nop();
        DAC8760_WriteReg (controlReg, DAC8760_WRITE_CONTROL_REGISTER);
        DAC8760_WriteReg (configurationReg, DAC8760_WRITE_CONFIGURATION_REGISTER);
        DAC8760_WriteReg (gainCalReg, DAC8760_WRITE_GAIN_CALIBRATION_REGISTER);
        DAC8760_WriteReg (zeroCalReg, DAC8760_WRITE_ZERO_CALIBRATION_REGISTER);
    
    }
    
    
    /*************************************************************************************************************************************************
     *  DAC8760_Reset
     **************************************************************************************************************************************************/
    /*!
     * @brief Sends a Reset Command to the DAC8760.
     *
     * This function sends a Reset command to the DAC8760 on the SPI bus.
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_Reset (void)
    {
        uint8_t outData[3];
        outData[0] = DAC8760_WRITE_RESET_REGISTER;
        outData[2] = DAC8760_RESET;
    
        DAC8760_SPIWrite (outData, RcvData);
    
    }
    
    /*************************************************************************************************************************************************
     *  DAC8760_Nop
     **************************************************************************************************************************************************/
    /*!
     * @brief Sends a Nop Command to the DAC8760.
     *
     * This function sends a Nop command to the DAC8760 on the SPI bus. The DAC8760 will timeout and move into an error state if it does not receive
     * regular commands for the SPI master. This command can be used to notify the DAC8760 that the system is still operational, but no change to the
     * DAC8760 is desired.
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_Nop (void)
    {
        uint8_t outData[3];
        outData[0] = DAC8760_WRITE_NOP_REGISTER;
        DAC8760_SPIWrite (outData, RcvData);
    
    }
    
    /*************************************************************************************************************************************************
     *  DAC8760_Set_Out_Value
     **************************************************************************************************************************************************/
    /*!
     * @brief Sets the output current from the DAC8760.
     *
     * The DAC8760 is designed to be used in a 4-20mAmp system. Data is communicated by changing the current output from the DAC8760. This function sets
     * the desired output current.
     *
     * @param[in]     value         Value to output from the DAC8760
     *
     * @return  None
     *
     **************************************************************************************************************************************************/
    void DAC8760_SetOutValue (uint16_t value)
    {
        DAC8760_WriteReg (value, DAC8760_WRITE_DATA_REGISTER);
    }
    
    /*************************************************************************************************************************************************
     *  DAC8760_Read_Status
     **************************************************************************************************************************************************/
    /*!
     * @brief Reads thE status register from the DAC8760.
     *
     * This function returns the current value in the status register of the DAC8760
     *
     * @return  DAC8760 Status     (DAC8760_FERR_STS, DAC8760_SPI_TIMEOUT_ERR, DAC8760_LOOP_STS, DAC8760_CURR_LOOP_STS)
     **************************************************************************************************************************************************/
    uint8_t DAC8760_ReadStatus (void)
    {
        uint8_t returnValue[3];
    
        DAC8760_ReadReg (returnValue, DAC8760_READ_STATUS_REGISTER);
    
        return (returnValue[2]);
    }
    
    
    
    Hi Garrett,

                 I have used the DACSPI libraries and converted it according to Renesas SPI...I DAC code all the functions contains SPI write and store the Recieve data in RCV Register.Please find the code in the attachment...Do we have to read from DAC 8760 or only write in the Ic.

  • Hi Firoz,

    I am not aware of any specific SPI libraries for Renesas. The code you provided looked fairly straight forward assuming the called functions from the header files work correctly. You can read and write from most of the DAC registers. This is specified in the register description in the datasheet. In most applications reading will be required to check the status register (alarm conditions) or other registers to ensure proper configuration.

    Thanks,
    Garrett
  • Hi Garret,

    I have converted the code for according to Renesas controller but the voltage Output remains zero whatever data i send to the DAC8760 .

  • Below is my code attached below.................



    #include "r_cg_macrodriver.h"
    #include "r_cg_port.h"
    #include "externfunct.h"
    #include "externvar.h"
    #include "r_cg_serial.h"
    #include"dac22.h"

    static unsigned char RcvData[3];

    /*************************************************************************************************************************************************
    * DAC8760_Write_Regs
    **************************************************************************************************************************************************/
    /*!
    * @brief Writes registers on the DAC8760.
    *
    * This function will execute a write register command to the DAC8760. This function can be used to update one register on the DAC8760.
    * No error checking is performed, so it is the user's responsibility to make sure they do not attempt to write past the end of the DAC8760 registers.
    *
    * @param[in] writeValues 16 bit register value to place in the DAC8760
    * @param[in] address Address of the register to write
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_WriteReg (uint16_t writeValues, uint8_t address)
    {
    uint8_t outData[3];

    outData[0] = address;

    // Switch Endianess
    outData[1] = writeValues >> 8;
    outData[2] = writeValues & 0xff;

    DAC8760_SPIWrite (outData, RcvData);

    }

    /*************************************************************************************************************************************************
    * DAC8760_Read_Regs
    **************************************************************************************************************************************************/
    /*!
    * @brief Reads registers on the DAC8760.
    *
    * This function will execute a read register command to the DAC8760 and return the resultant data. This function can be used to read one or more
    * registers from the DAC8760. No error checking is performed, so it is the user's responsibility to make sure they do not attempt to read past
    * the end of the DAC8760 registers.
    *
    * @param[out] *readValues Pointer to place the 8 bit register values from the DAC8760
    * @param[in] address Address of the register to read
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_ReadReg (uint8_t *readValues, uint8_t address)
    {
    uint8_t outData[3] = {0x55, 0x55, 0x55};

    // Sets the address for the read command
    outData[0] = DAC8760_READ_REGISTER;
    outData[2] = address;
    DAC8760_SPIWrite (outData, readValues);

    // Performs actual read of previous address
    outData[0] = DAC8760_WRITE_NOP_REGISTER;
    DAC8760_SPIWrite (outData, readValues);

    }

    /*************************************************************************************************************************************************
    * Setup_DAC8760
    **************************************************************************************************************************************************/
    /*!
    * @brief Performs the setup of the DAC8760.
    *
    * This function will configure the DAC8760.
    *
    * @param[in] controlReg Value written into DAC8760_CONTROL_REGISTER
    * @param[in] configurationReg Value written into DAC8760_CONFIGURATION_REGISTER
    * @param[in] gainCalReg Value written into DAC8760_GAIN_CALIBRATION_REGISTER
    * @param[in] zeroCalReg Value written into DAC8760_ZERO_CALIBRATION_REGISTER
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_Setup (uint16_t controlReg, uint16_t configurationReg, uint16_t gainCalReg, uint16_t zeroCalReg)
    {
    unsigned char i;
    //DAC8760_SPISetupMaster();
    DAC8760_Reset();
    // for(i=0;i<1000;i++);
    DAC8760_Nop();
    // for(i=0;i<1000;i++);
    DAC8760_WriteReg (controlReg, DAC8760_WRITE_CONTROL_REGISTER);
    // for(i=0;i<1000;i++);
    DAC8760_WriteReg (configurationReg, DAC8760_WRITE_CONFIGURATION_REGISTER);
    // for(i=0;i<1000;i++);
    DAC8760_WriteReg (gainCalReg, DAC8760_WRITE_GAIN_CALIBRATION_REGISTER);
    // for(i=0;i<1000;i++);
    DAC8760_WriteReg (zeroCalReg, DAC8760_WRITE_ZERO_CALIBRATION_REGISTER);

    }


    /*************************************************************************************************************************************************
    * DAC8760_Reset
    **************************************************************************************************************************************************/
    /*!
    * @brief Sends a Reset Command to the DAC8760.
    *
    * This function sends a Reset command to the DAC8760 on the SPI bus.
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_Reset (void)
    {
    uint8_t outData[3];

    DAC_CSN=1;//cs_asic=1;
    DAC_CLK=0;//sclk_asic=0;
    DAC_OUT=0;//dout_asic=0;
    DAC_IN=1;//din_asic=1;

    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    outData[0] = DAC8760_WRITE_RESET_REGISTER;
    outData[2] = DAC8760_RESET;

    DAC8760_SPIWrite (outData, RcvData);

    }

    /*************************************************************************************************************************************************
    * DAC8760_Nop
    **************************************************************************************************************************************************/
    /*!
    * @brief Sends a Nop Command to the DAC8760.
    *
    * This function sends a Nop command to the DAC8760 on the SPI bus. The DAC8760 will timeout and move into an error state if it does not receive
    * regular commands for the SPI master. This command can be used to notify the DAC8760 that the system is still operational, but no change to the
    * DAC8760 is desired.
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_Nop (void)
    {
    uint8_t outData[3];
    outData[0] = DAC8760_WRITE_NOP_REGISTER;
    DAC8760_SPIWrite (outData, RcvData);

    }

    /*************************************************************************************************************************************************
    * DAC8760_Set_Out_Value
    **************************************************************************************************************************************************/
    /*!
    * @brief Sets the output current from the DAC8760.
    *
    * The DAC8760 is designed to be used in a 4-20mAmp system. Data is communicated by changing the current output from the DAC8760. This function sets
    * the desired output current.
    *
    * @param[in] value Value to output from the DAC8760
    *
    * @return None
    *
    **************************************************************************************************************************************************/
    void DAC8760_SetOutValue (uint16_t value)
    {
    DAC8760_WriteReg (value, DAC8760_WRITE_DATA_REGISTER);
    }

    /*************************************************************************************************************************************************
    * DAC8760_Read_Status
    **************************************************************************************************************************************************/
    /*!
    * @brief Reads thE status register from the DAC8760.
    *
    * This function returns the current value in the status register of the DAC8760
    *
    * @return DAC8760 Status (DAC8760_FERR_STS, DAC8760_SPI_TIMEOUT_ERR, DAC8760_LOOP_STS, DAC8760_CURR_LOOP_STS)
    **************************************************************************************************************************************************/
    uint8_t DAC8760_ReadStatus (void)
    {
    uint8_t returnValue[3];

    DAC8760_ReadReg (returnValue, DAC8760_READ_STATUS_REGISTER);

    return (returnValue[2]);
    }
    /******************************FUNCTIONS forSPI Write*********************************************************************************************/
    void DAC8760_SPIWrite (uint8_t *outData, uint8_t *inData)
    {
    uint8_t i;

    for (i=0; i<3; i++)
    {
    inData[i] = SPI_TransRec_byte(outData[i]);
    }

    // Load DAC registers input.
    // A rising edge on the Latch pin loads the input shift register data into the DAC data and control registers and updates the DAC outputs.
    DAC_CSN=0;//DAC8760_LATCH_PORTOUT |= DAC8760_LATCH_PIN;
    NOP();//__delay_cycles(1); // delay min 40ns
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    DAC_CSN=1;//DAC8760_LATCH_PORTOUT &= ~DAC8760_LATCH_PIN;
    }
    /*************************************************************************************************************************************************/
    /**************************************************************SPI_TRANSrec***********************************************************************/
    unsigned char SPI_TransRec_byte(unsigned char mtrs)
    {
    unsigned char i,maskdata,readdata;
    unsigned char m_rcv,m_trs,opr_data;
    unsigned char temp0;

    m_trs=mtrs;
    m_rcv = 0x00; /* Initialize m_rcv[] */


    DAC_CLK=0;//sclk_asic=0;
    DAC_OUT=0;//dout_asic=0;

    DAC_CSN=0;//cs_asic=0;
    NOP();
    NOP();
    NOP();
    NOP();

    //for (i=0;i<5;i++)
    {
    maskdata=0x80;
    while (maskdata)
    {
    Clr_WatchDog();
    readdata = m_rcv | maskdata;
    if (m_trs& maskdata) // "H" output ?
    DAC_OUT=1;//dout_asic = 1; // Yes SDA="H"
    else
    DAC_OUT=0;//dout_asic = 0;
    if (DAC_IN) // SDA="H" ?
    m_rcv = readdata; // Yes
    maskdata >>= 1;
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    DAC_CLK=1;//sclk_asic =1;
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    DAC_CLK=0;//sclk_asic=0;
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    NOP();
    }
    }
    DAC_CSN=1;//cs_asic=1;
    m_rcv=0; //(unknown) byte received when command is sent

    //opr_data[3] = 0;
    //opr_data[2] = m_rcv[1];
    //opr_data[1] = m_rcv[2];
    opr_data = m_rcv;


    temp0 = opr_data;
    return temp0;
    }
    /*********************************************************************************************************************************************/
  • Hi Firoz,

    I saw that you sent me a similar direct message on the forum and thought I would just reply directly to the thread.

    As we are not really Renesas experts, debugging code isn't our forte. Instead, I would suggest that we look at things from more of a HW perspective.

    If you can provide oscilloscope captures of the LATCH, SDI, SDO, and SCLK pins we can verify whether the physical signals are correct or not.

    Additionally, a schematic to verify connections would be helpful.

  • Hi Kevin,

                    Please find the Schematic,DAC8760 PCB and the Waveforms of SCLK,LATCH,MISO,MOSI ANdac8760_DATA.zipD ALARM PINS...

  • Hi Firoz,

    I apologize for not being specific. We need to examine the relative timing of the digital signals, as opposed to the individual characteristics of each signal. Specifically - we would want to see a single oscilloscope capture with all four digital signals, ideally zoomed in a bit more so we can see the details of elements like setup and hold time.

    I would also point out that it looks like the ALARM pin is low - so some alarm has triggered for the DAC. I do not believe the IOUT open circuit alarm functions when IOUT is disabled - so most likely this is a thermal alarm. I am curious if potentially the exposed thermal pad on the bottom side of the DAC is touching the solder pads on your debug board since most likely the landing pattern on this breakout board was not designed with thermal pads or the DAC8760 in mind.
  • Hi Duke,

               Sorry I do not have extra probes to measure the signals and comapre them.I have solved the Voltage Output Section,Now i am Able to Write Values in the DAC Write Registers and vary the  VOUT voltage.But still My Current section is not working whenever I configure the Current output controlling bits in the configuration Register the ALARM Pin goes LOW .There is no Thermal Issue as I have covered the thermal pad with insulation tape below the IC.

  • Hi Firoz,

    It is difficult to confirm correct SPI transmission without capturing the signals simultaneously. It seems that the SPI is transmitting correctly at least when you test the voltage output.

    1. What is the voltage/current measured at IOUT in the alarm condition and what load are you using. Ensure that the load is connected correctly as open circuit will trigger the alarm.

    2. Can you read the status register? The lower 5 bits of this register contain the alarm conditions. This will help identify what is triggering the alarm.

    Thanks,
    Garrett
  • Hi Firoz,

    Do you have any update on this?

    Thanks,
    Garrett