工具与软件:
我的设计在 两条单独的 I2C 总线上具有5个 DAC7678SPW DAC。 在此应用中、我要写入40个 DAC 通道中除5个通道之外的所有通道、然后将 LDAC 引脚切换为低电平然后切换为高电平、以便同时将数据传输到 DAC。 但是、这似乎不起作用。
下面的一些示例代码不起作用:
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; }
如果我只更改了一行代码、将用于写入 DAC 输入电阻器的命令从(0x00|dacch)更改为(0x30|dacch)以在每次写入后更新 DAC 通道(不等待 LDAC)、则所有 DAC 通道都将正确更新。
我已经通过示波器检查 LDAC 引脚变为低电平50us、但 DAC 未更新。
非常感谢您提供任何帮助或示例代码。
谢谢!
David