Post Go back to editing

Readback in AD5758

We are using AD5758 in our design. We have used the example code given for AD5758. Connected VIout to Vsense+. 

 We are able to change the DAC output but not able to readback using 2 stage readback as well as auto status readback.

Status is always read as zero.

Can you please share steps to configure the ADC of AD5758 and read the Vsense+

Parents
  • We are trying to configure the ADC by calling following functions.

             ad5758_select_adc_ip(dev, ADC_IP_VSENSE);

             ad5758_set_adc_channel_input(dev, 0, ADC_IP_VSENSE);

             ad5758_set_adc_mode(dev, ADC_MODE_SINGLE_CONV, 1);

    And read the data by calling

             ad5758_read_status(dev, &status))

             

  • Hi,

    It looks like the example code functions are not quite right for a single conversion. To do a single conversion a single write to the ADC config is required. (In the ADC_Config register bits 10:8 should be 100, bits 7:5 are don't care, bits 4:0 should be the input node to be measured.

    You could edit the below function by changing the AD5758_ADC_CONFIG_SEQUENCE_COMMAND_MODE from 0x01 to 0x04. (Highlighted in bold) 

    int32_t ad5758_set_adc_channel_input(struct ad5758_dev *dev, uint8_t channel, enum ad5758_adc_ip adc_ip_sel)
    {
             uint16_t cmd;
             int32_t ret;

    cmd = (AD5758_ADC_CONFIG_SEQUENCE_COMMAND_MODE(0x04) |
                AD5758_ADC_CONFIG_SEQUENCE_DATA_MODE(channel) |
                AD5758_ADC_CONFIG_ADC_IP_SELECT_MODE(adc_ip_sel));

    ret = ad5758_spi_reg_write(dev, AD5758_REG_ADC_CONFIG, cmd);

    if (ret < 0) {
        printf("%s: Failed.\n", __func__);

        return FAILURE;
    }

    return SUCCESS;

    }

    After you apply the above change call ad5758_set_adc_channel_input(dev, 0, ADC_IP_VSENSE) to configure a single conversion on +VSENSE. If 2 stage readback is enabled then read the status register to get the ADC data. 

    For the autostatus readback, you must enable bit 5 in the Two Stage Readback Select Register. Every SPI frame sent to the AD5758 will result in the status register shifted out on the SDO pin. 

    Regards,

    Valerie

  • I already tried this AD5758_ADC_CONFIG_SEQUENCE_COMMAND_MODE(0x04)

    and did same steps as you mentioned ad5758_set_adc_channel_input(dev, 0, ADC_IP_VSENSE)

    But then when I try to read status I am always getting zero.

  • There are 2 possibilities for reading 0, 1. The ADC is not configured correctly, 2. The readback configuration is not correct. Can you read another register? e.g. the DAC Config should have non zero data to check the readback?

    Also, is this 2 stage or autostatus readback you are using?

    Valerie

  • Using 2-stage readback STM32F105 to AD5758, tried registers 0x14 and 0x16, as follows (SPI CRC off),

    ...and still get all zeroes for the reads, status register (0x16) or other (0x14)

    How about some sample code to read registers ?

    :

            //note: clock CS (SYNC) low to high, DAC data converted on rising edge of CS (SYNC), AD0=0, AD1 = 1
      uint8_t testA_pTxData[4];//24bits to be used if no CRC, else 32bits, last 8bits ignored if no CRC
      uint8_t testA_pRxData[4];
          

     HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_RESET);//select shared interface to DAC, on SPI1 PA4 (active low)
            osDelay(1); //wait state after reset
            testA_pTxData[0] = 0x53;//Address: 0x13, 010 1 0011,
            testA_pTxData[1] = 0x00;//xxxx xxxx
            testA_pTxData[2] = 0x14;//xxx0 0000 0x14, 0x15, 0x16 status register
            testA_pTxData[3] = 0x00;//CRC or ignored
            hRet = HAL_SPI_Transmit(&hspi1, testA_pTxData, sizeof(testA_pTxData), HAL_MAX_DELAY);//xmit desired words to DAC
            osDelay(1); //wait state after reset
            //complete register write(s)
            HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_SET);//deselect shared interface to DAC, on SPI1 PA4 (active low)
            osDelay(1); //wait state after reset

    //then write NOP register to get register selected contents on SDO (spi receive)
            HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_RESET);//select shared interface to DAC, on SPI1 PA4 (active low)
            testA_pTxData[0] = 0x40;//Address: 0x00, 010 0 0000,
            testA_pTxData[1] = 0x00;//xxxx xxxx
            testA_pTxData[2] = 0x00;//xxxx xxxx
            testA_pTxData[3] = 0x00;//CRC or ignored
            hRet = HAL_SPI_Transmit(&hspi1, testA_pTxData, sizeof(testA_pTxData), HAL_MAX_DELAY);//xmit desired words to DAC
            osDelay(1); //wait state after reset
            //complete register write(s)
            HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_SET);//deselect shared interface to DAC, on SPI1 PA4 (active low)
            osDelay(1); //wait state after reset

                //see page 47 of DAC datasheet
            HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_RESET);//select shared interface to DAC, on SPI1 PA4 (active low)
                //Read 34 bytes
                hRet = HAL_SPI_Receive(&hspi1,testA_pRxData,4,100);
                osDelay(1); //wait 500us min
                //complete register write(s)
                HAL_GPIO_WritePin(GPIOA, SPI1_CS1_0_Pin, GPIO_PIN_SET);//deselect shared interface to DAC, on SPI1 PA4 (active low)
                osDelay(1); //wait state after reset

  • Hi,

    You need to disable the SPI CRC setting (Bit 0 in register 0x10) before the part will accept 24 bit frames (This must be done with a CRC as the part will only accept 32 bit frames until this bit is disabled). See post https://ez.analog.com/data_converters/precision_dacs/f/q-a/548467/disable-crc-ad5758

    Valerie

Reply Children
No Data