Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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.

DAC53401EVM: DAC53401 EVM

Part Number: DAC53401EVM

Write a code in arduino but I am not getting correct DAC result at Vout pin , constantly i read wrong values , just check my code and let me know 

#include <Wire.h>

#define devId 0x50 // DAC device ID
#define regDAC 0x40 // DAC register address
#define VREF 3 // DAC reference voltage
#define DAC_RESOLUTION 1024 // DAC resolution (8-bit)

// Function to reset the DAC
void dac_reset() {
Wire.beginTransmission(devId);
Wire.write(regDAC);
Wire.write(0x06);
Wire.endTransmission();
}

// Function to power on the DAC
void dac_power_on() {
Wire.beginTransmission(devId);
Wire.write(regDAC);
Wire.write(0x0F);
Wire.endTransmission();
}

// Function to power off the DAC
void dac_power_off() {
Wire.beginTransmission(devId);
Wire.write(regDAC);
Wire.write(0x00);
Wire.endTransmission();
}

// Function to lock the DAC
void dac_lock() {
Wire.beginTransmission(devId);
Wire.write(0xD3);
Wire.write(0x50);
Wire.endTransmission();
}

// Function to set the DAC's output voltage
void set_dac_output_voltage(double voltage) {
// Calculate the DAC code based on the desired voltage
int dacCode = (int)(voltage / VREF * DAC_RESOLUTION);

// Write the DAC code to the register
Wire.beginTransmission(devId);
Wire.write(0x21);
Wire.write(dacCode);
Wire.endTransmission();
}

void setup() {
Wire.begin();
Serial.begin(9600);

// Reset the DAC
// dac_reset();

// Power on the DAC
dac_power_on();
dac_lock();
// Perform other initialization tasks...
}

void loop() {
// Measure the DAC value continuously

// Set the DAC output voltage to 2.5V
set_dac_output_voltage(3.0);

// Read the DAC value
Wire.requestFrom(devId, 1); // Request 1 byte from the DAC
if (Wire.available()) {
int dacCode = Wire.read();
double voltage = (double)dacCode / DAC_RESOLUTION * VREF;

// Print the measured voltage
Serial.print("DAC Value: ");
Serial.print(dacCode);
Serial.print(" Measured Voltage: ");
Serial.print(voltage, 2);
Serial.println(" V");
}

// Add a delay if needed
delay(1000);
}

  • Hi Rahul, 

    How does the Arduino usually accept the device address? The 7-bit device address when A0 is pulled to ground would be 0x48. 8-bit address would be 0x90 considering the W/W bit to be 0. I don't think any of the A0 settings would result in an address of 0x50. 

    Follow the table based on what you have A0 connected to:

    Can you share a zoomed in screenshot of one of your write commands with SCL and SDA shown? Ideally the full command zoomed in so I can clearly see the rising and falling edge of each SCL pulse. 

    Best,

    Katlynne Jones