Other Parts Discussed in Thread: DAC63204
sorry it took some time to jump back onto DAC project again. as mentioned earlier I'm using below code. but it seems that DAC value is not updated.
I'm hex values to update DAC voltage. eg. ( 0x708 for 7.44v, 0x604 for 8.3v etc)
here is my code ;;;;;;;
// Function to configure OUT0 on DAC53202RTER
void configure_out0(void) {
ret_code_t err_code;
// Configure DAC53202RTER for OUT0
uint8_t common_config_data[2] = {0x1F, 0x03FF}; // Set OUT0 in voltage output mode
uint8_t gain_config_data[2] = {0x15, 0x0400}; // Set gain for OUT0 (use VDD as the reference)
// Send I2C start condition and write COMMON-CONFIG register data
err_code = nrf_drv_twi_tx(&m_twi, DAC53202RTER_I2C_ADDRESS, common_config_data, sizeof(common_config_data), false);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_ERROR("I2C transaction failed with error code: %d", err_code)
NRF_LOG_FLUSH();
}
// Send I2C start condition and write DAC-0-VOUT-CMP-CONFIG register data
err_code = nrf_drv_twi_tx(&m_twi, DAC53202RTER_I2C_ADDRESS, gain_config_data, sizeof(gain_config_data), false);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_ERROR("I2C transaction failed with error code: %d", err_code)
NRF_LOG_FLUSH();
}
// Optionally, add a delay to allow the DAC to settle
nrf_delay_ms(10);
}
// Function to update the OUT0 output value
void update_out0(uint16_t output_value) //output_value are hex codes (ex. 0x708 for 7.44v & 0x00 for 16v)
{
ret_code_t err_code;
// Update the OUT0 output using the DAC-0-DATA register
uint8_t data_register_data[3] = {0x1C, (output_value >> 8) & 0xFF, output_value & 0xFF};
// Send I2C start condition and write DAC-0-DATA register data
err_code = nrf_drv_twi_tx(&m_twi, DAC53202RTER_I2C_ADDRESS, data_register_data, sizeof(data_register_data), false);
if (err_code != NRF_SUCCESS)
{
NRF_LOG_ERROR("I2C transaction failed with error code: %d", err_code)
NRF_LOG_FLUSH();
}
// Optionally, add a delay to allow the DAC to settle
nrf_delay_ms(10);
}



