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.

DAC80501: DAC80501

Part Number: DAC80501

Tool/software:

Hai all I am using the DAC80501 for generating the 20mV and 40mV and here I am using external 2.5Ref voltage and the VDD is 3.3V.

this is my SPI configuration

void MX_SPI1_Init(void)

{

/* USER CODE BEGIN SPI1_Init 0 */

/* USER CODE END SPI1_Init 0 */

/* USER CODE BEGIN SPI1_Init 1 */

/* USER CODE END SPI1_Init 1 */

/* SPI1 parameter configuration*/

hspi1.Instance = SPI1;

hspi1.Init.Mode = SPI_MODE_MASTER;

hspi1.Init.Direction = SPI_DIRECTION_2LINES;

hspi1.Init.DataSize = SPI_DATASIZE_8BIT;

hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;

hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;

hspi1.Init.NSS = SPI_NSS_SOFT;

hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;

hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi1.Init.CRCPolynomial = 0x0;

hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;

hspi1.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;

hspi1.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;

hspi1.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

hspi1.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

hspi1.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;

hspi1.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;

hspi1.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;

hspi1.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;

hspi1.Init.IOSwap = SPI_IO_SWAP_DISABLE;

if (HAL_SPI_Init(&hspi1) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN SPI1_Init 2 */

/* USER CODE END SPI1_Init 2 */

}

main function

int main(void)

{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */

SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_SPI1_Init();

/* USER CODE BEGIN 2 */

uint8_t cmd_1 = 0x05;

uint16_t data_1 = 0x000A;

uint8_t cmd_2 = 0x04;

uint16_t data_2 = 0x0100; //0x0001;

uint8_t cmd_3 = 0x08;

uint16_t data_3 = 0x0418; //0xFFFF;

write_dac80501(cmd_1, data_1);

HAL_Delay(10);

write_dac80501(cmd_2, data_2);

write_dac80501(cmd_3, data_3);

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

}

/* USER CODE END 3 */

}

DAC function

void write_dac80501(uint8_t command, uint16_t value)

{

uint8_t send_data[3] = {0x00};

send_data[0] = command;

send_data[1] = (value >> 8) & 0xFF;

send_data[2] = value & 0xFF;

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6, GPIO_PIN_SET);

HAL_Delay(1);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6, GPIO_PIN_RESET);

if(HAL_SPI_Transmit(&hspi1, send_data, 3, HAL_MAX_DELAY) != HAL_OK)

{

Error_Handler();

}

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6, GPIO_PIN_SET);

}
In DAC out I am getting 0V. even I tried with (0xffff) even though iam getting 0V, Please help me where i am doing mistake.

Thank you.

 

 

  • Hi Naveen, 

    Your SPI mode may be incorrect. It looks like you have set the SPI polarity to low, and phase to first edge. This DAC captures data on the falling edge. Try swapping the phase to the second edge which would be the falling edge with a low polarity clock. Please let me know if I'm misinterpreting your settings. 

    Best,

    Katlynne Jones

  • Hi Katlynne,

    Thank you for your response.

    I have changed the SPI settings to use the second clock edge, and I am currently getting 1.2V on the DAC output. I do have a question regarding the external 2.5V reference voltage. To enable this, I understand that I need to send 0x0001 to the gain register. However, when I do this, the DAC output shows 0V.

    On the other hand, when I send 0x0100, which I believe sets the DAC to use the internal reference voltage, I get 1.2V on the DAC output while sending 0xFFFF as the DAC data. Could you please check if I am making any mistakes in this setup?

    Thank you in advance for your help!

  • Hi Naveen, 

    To enable the external reference, all you need to do is disable the internal reference in the config register. The gain register controls the reference divider, and the output buffer gain. The reference buffer in this device requires enough headroom to operate, or else it'll automatically output a 0V reference to the DAC and you'll see the 0V output for any code. 

    Writing 0x0100 divides the reference by 2, ensuring that the reference has enough headroom based on your 3.3V supply. You can write 0x0101 to get a full-scale output of 2.5V. This sets the output buffer gain to x2 to cancel out the reference divider. 

    You can also write 0x0001, or 0x0000 and increase your supply to 5V to resolve this behavior. 

    Best,

    Katlynne Jones

  • Hi Naveen,

    The two bits in the GAIN register are the BUFF-GAIN bit (which applies a 1x or 2x gain to the output buffer) and the REF-DIV bit (which will divide the reference by 1x or 2x). The REF DIV bit applies whether you are using the internal or external reference.

    When using a 2.5V reference and a VDD voltage under ~3.5V, you have to set the reference divider bit. This is due to the external buffer limitations, as it requires a certain amount of headroom between the reference and VDD to operate. In this configuration, you will effectively be providing a reference of 1.25V, as the device will divide the 2.5V by 2. This is why you see ~1.2V as the full-scale voltage.

    To set the full-scale range to 2.5V, you should set the BUFF-GAIN bit to 1. So, the full command to send to the Gain register will be 0x0101. This will give you a 0V - 2.5V output range. In a bit of a roundabout way, this is taking your 2.5V reference, dividing it to 1.25V, then multiplying it by 2 back to 2.5V. If for whatever reason you require a higher range, you will need to increase your VDD voltage.

    Additionally, the register that disables the internal reference is the CONFIG register (0x03). You are likely already setting this, but make sure to write 0x0100 to disable the internal reference if you intend to use an external reference.

    Thanks,
    Erin

  • Hai Katlynne,


    Thank you for your suggestion. I am now able to successfully generate 2.5V on the DAC output using an external reference voltage. Your guidance has been invaluable in achieving this outcome.