Tool/software:
I have a design that has 5 DAC7678SPW DACs on two separate I2C buses. In this application, I want to write to all but 5 of the 40 DAC channels then toggle the LDAC pin low then high to transfer the data to the DACs all at the same time. However, this does not seem to work.
Some example code is below that does not work:
HAL_StatusTypeDef dacsUpdate35(uint16_t daca[35]) { static const uint8_t udacadr[] = {DAC0ADR, DAC1ADR, DAC2ADR, DAC3ADR, DAC4ADR}; HAL_StatusTypeDef ret; uint8_t dacch; uint8_t i2cadr; // write the wavelength data for all wavelengths (update the outputs later) for (dacch=0; dacch<QTY_WAVELEN; dacch++) { // determine the the DAC I2C address i2cadr = udacadr[dacch>>3]; // build the data to send to the DAC uint8_t dat[3] = { // 0x30|(dacch&7), /* command to write the DAC channel and update its output */ (dacch&7), /* command to write the DAC channel but don't update the output yet */ daca[dacch]>>4, /* top 8 bits of the dac setting, left justified */ daca[dacch]<<4 /* bottom 4 bits of the dac setting, left justified */ }; // write the dac if ( dacch < 24 ) ret = HAL_I2C_Master_Transmit(&hi2c4, i2cadr, dat, 3, HAL_MAX_DELAY); else ret = HAL_I2C_Master_Transmit(&hi2c3, i2cadr, dat, 3, HAL_MAX_DELAY); if (ret != HAL_OK) goto ERRXIT; } // all wavelength DAC data has now been written to the DAC registers but the // outputs have not been updated yet. ERRXIT: // toggle the DAC_LDAC line to transfer all DAC registers to their outputs LL_GPIO_ResetOutputPin(nDAC_LDAC_GPIO_Port, nDAC_LDAC_Pin); delay_us(50); LL_GPIO_SetOutputPin(nDAC_LDAC_GPIO_Port, nDAC_LDAC_Pin); return ret; }
If I change just one line of code that sets the command to write to the DAC input resister from (0x00|dacch) to (0x30|dacch) to update the DAC channel after each write (doesn't wait for LDAC), all of the DAC channels are correctly updated.
I have checked that the LDAC pin is going low 50us with a scope, but the DACs are not updated.
Any help or example code would be greatly appreciated.
Thank you,
David