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: can not read data

Part Number: DAC8760

Hi, expert

My customer is using DAC8760 pin to pin replace AD5421, but they found no data from DAC output.

They can write into the register to adjust the output current, but when they read the DAC data, the SDO is always low. (LATCH/SCK/SDIN signals are correct)

Attached their code, could you please help analysis this problem? Thanks

Best Regards.

Chen

DAC-DEMO.c
    static unsigned	char buf[3] = {0,0,0};
    static unsigned	char buf2[3] = {0,0,0};
    statc Modechange=1;
    static SetAoValue=0xD554;//20MA
    static ReadFromAoStatus=0;
    static ReadFromAoData=0;
    static ReadFromAoCtrl=0;

//the function write data to the ADC's register (DAC)
void WriteToADC(unsigned char count,unsigned char *buf)
{
    unsigned	char	ValueToWrite = 0;
    unsigned	char	i = 0;
    unsigned	char	j = 0;


//set latch low
    GPIOPinWrite(DAC_LATCH_PORT, DAC_LATCH_PIN, ~DAC_LATCH_PIN);

    for ( i=count; i>0; i-- )
    {
        ValueToWrite =	*(buf+i-1);
        for (j=0; j<8; j++)
        {
            GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,~DAC_SCK_PIN);
            if(0x80 == (ValueToWrite & 0x80))
            {
                GPIOPinWrite(DAC_SDI_PORT, DAC_SDI_PIN,DAC_SDI_PIN); //Send one to SDIN pin of AD5422
            }
            else
            {
                GPIOPinWrite(DAC_SDI_PORT, DAC_SDI_PIN,~DAC_SDI_PIN); 	    //Send zero to SDIN pin of AD5422
            }

            SysDelayUs(1);
            GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,DAC_SCK_PIN);
            SysDelayUs(1);
            ValueToWrite <<= 1;	                      //Rotate data
        }
    }

    GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,~DAC_SCK_PIN);
    SysDelayUs(1);
    GPIOPinWrite(DAC_LATCH_PORT, DAC_LATCH_PIN, DAC_LATCH_PIN);
    //  SysDelayUs(20);
    SysDelayUs(10);

}


//the function read the data register from DAC
void ReadFromADC(unsigned char count,unsigned char *buf)
{
    unsigned	char	i = 0;
    unsigned	char	j = 0;
    unsigned	char  	iTemp = 0;
    unsigned	char  	RotateData = 0;

    GPIOPinWrite(DAC_LATCH_PORT, DAC_LATCH_PIN, ~DAC_LATCH_PIN);

    for(j=count; j>0; j--)
    {
        for(i=0; i<8; i++)
        {
            GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,~DAC_SCK_PIN);
            RotateData <<= 1;		                            //Rotate data
            SysDelayUs(1);
            GPIOPinWrite(DAC_SDI_PORT, DAC_SDI_PIN,~DAC_SDI_PIN);		       //Write a nop condition when read the data.
            iTemp = GPIOPinRead(DAC_SDO_PORT,DAC_SDO_PIN);			   //Read SDO of AD5422
            GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,DAC_SCK_PIN);
            if(iTemp == 1)
            {
                RotateData |= 1;
            }
            SysDelayUs(1);
        }
        *(buf+j-1)= RotateData;
    }

    GPIOPinWrite(DAC_SCK_PORT, DAC_SCK_PIN,~DAC_SCK_PIN);
    SysDelayUs(1);
    GPIOPinWrite(DAC_LATCH_PORT, DAC_LATCH_PIN, DAC_LATCH_PIN);
    // SysDelayUs(20);
    SysDelayUs(10);
}



void DacDemo(void)
{
//IO���ų�ʼ����ʹ��GPIOģ��SPI


//set control
//�趨0-24MA���
if(Modechange)
{
   Modechange=0;
   buf[0]=0x07;//0-24ma
   buf[2]=0x55;
   buf[1]=0x10;
   WriteToADC(3,buf);//�趨״̬
   SysDelayUs(100);
}

//ͨ�������趨
    buf[2] = 0x01;              //Data register
    buf[1] = (SetAoValue>>8)&0xff;
    buf[0] = SetAoValue&0xff;
    WriteToADC(3,buf);//
    SysDelayUs(100);

 //ͨ��״̬�ز�
    buf[2] = 0x02;//READ
    buf[1] = 0x00;
    buf[0] = 0x00;//STATUS
    WriteToADC(3,buf);
    ReadFromADC(3,buf2);
    ReadFromAoStatus=buf2[1];
    ReadFromAoStatus<<=8;
    ReadFromAoStatus+=buf2[0];
    SysDelayUs(100);

//ͨ�����ݻز�
    buf[2] = 0x02;//READ
    buf[1] = 0x00;
    buf[0] = 0x01;//DATA
    WriteToADC(3,buf);
    ReadFromADC(3,buf2);
    ReadFromAoData=buf2[1];
    ReadFromAoData<<=8;
    ReadFromAoData+=buf2[0];
    SysDelayUs(100);

//ͨ�����ƻز�
    buf[2] = 0x02;//READ
    buf[1] = 0x00;
    buf[0] = 0x02;//control
    WriteToADC(3,buf);
    ReadFromADC(3,buf2);
    ReadFromAoCtrl=buf2[1];
    ReadFromAoCtrl<<=8;
    ReadFromAoCtrl+=buf2[0];
    SysDelayUs(100);
}

  • Hi Chen,

    We will get a response to you on Monday.

    Thanks,

    Paul

  • Chen,


    Can they write to a register and read the same register back from the device? I want to make sure they're able read things back. Note that the default settings for this device are all zeros, so reading back all zeros from the register is not useful. They would need to write a different value and read it back. It does look like they have some readback programmed into their code. Just to be sure, they should read back all registers to make sure they are as they expect. I would also want this to know what values they've programmed in.

    If DOUT is always low, they should check the physical connections to the DAC and look at the digital lines and also ground. They should check that the control line from the microcontroller connects to the DAC. It's possible that one of the digital lines is misconnected or unconnected. After that, they should also check the digital lines with an oscilloscope. The digital communication should match and follow the timing diagrams in the datasheet. After they verify the digital connections, they should get a scope shot of the communication and post it back here.

    After that, I would check the other physical connections and the circuit connections to the device. Can they provide a schematic for their circuit? I would want to see how they have the device set up and connected to the microcontroller. I would check the power supplies, the reference voltage, and the ground to the device. I would also look at the CLR pin just to see that it isn't always high.

    I don't see anything in the code that would be a problem. However, there usually isn't enough information in the code to debug a problem like this. It's always best to start by looking at the circuit and physical connections to the device.


    Joseph Wu

  • Chen,

    I haven't heard back from you, so I thought I'd check in with this problem. Has your customer gotten the communication working? In my last post, I made a few suggestions for debugging the circuit. I highly recommend using a logic analyzer to debug the digital communication and matching the output with the timing diagrams of the datasheet.

    For now, I'll close this thread. Hopefully, your customer has solved this problem. If they haven't, post back and we'll continue working on this thread.

    Joseph Wu