Tool/software:
Hi All,
I'm trying to interface the DAC6571 using I2C with nxp RT1020 imx.8 processor .
I2c is configuration is like it open drain enabled and 4.7K pull up connected on SDA and SCL pin on Hardware.
I confirmed that the I2C is working properly but chip is giving proper data on Vout pin of chip.
check below code:
#define I2C_SLAVE_DAC6571_ADDR_7BIT 0x4CU//(0x98U >> 1)
#define DAC_MASK_VALUE 0x03FF
// DAC value should be 10 bits, so mask it to ensure it doesn't exceed 10 bits
value &= DAC_MASK_VALUE;
// Prepare the data to be sent in the required format
UINT8 data[2];
data[INDEX0] = (value >> 6) & 0x0F; // Upper 4 bits of the 10-bit value
data[INDEX0] |= 0x00; // for normal operation Set two power-down bits to zero
data[INDEX1] = (value << 2) & MAX_8BIT; // Lower 6 bits of the 10-bit value followed by two don't care bits
// LPI2C master descriptor
lpi2c_master_transfer_t masterXfer = {0};
status_t reVal = kStatus_Fail;
/* subAddress = 0x01, data = g_master_txBuff - write to slave.
start + slaveaddress(w) + subAddress + length of data buffer
+ data buffer + stop*/
masterXfer.slaveAddress = I2C_SLAVE_DAC6571_ADDR_7BIT;
masterXfer.direction = kLPI2C_Write;
masterXfer.data = data; //(0 to 1023)
masterXfer.dataSize = sizeof(data);
masterXfer.flags = kLPI2C_TransferDefaultFlag;
// Send master non-blocking data to slave
reVal = LPI2C_MasterTransferEDMA(I2C_MASTER, &g_m_edma_handle, &masterXfer);
if (reVal != kStatus_Success)
{
return DAC_STATUS_FAIL;
}
// Wait for transfer completed.
while (!g_MasterCompletionFlag)
{
// Do Nothing
}
g_MasterCompletionFlag = false;
With this code dac giving me random values .
The expected output is like on Vout pin i will have to get when i set
value = 0 then Vout should 0V
and value = 1000 then Vout should 3.3V likewise i want from dac but currently it is not giving proper
Please suggest me ASAP.
for more info please check(nxp community link)
Best reagrds.
Hanmant