这个芯片资料非常简单,单纯看pdf文档很难选择出正确的地址。
在官方技术讨论区正好看到有这个地址的询问,特此记录下。
Question for connecting DAC101C081 with MSP430F5172
I recently met a problem. I tried to connect the DAC101C081 (6 pins, I2C) as slave mode with MSP430 (master mode).
I connected ADR0 of DAC to GND and Va to 5V. However, when I tried to transmit the data from MSP to DAC,
even if I set the slave address as 0x0Dh as datasheet, I could not receive the ACK from DAC. Could anyone provide the suggestion?
Hello,
The address when communicating with the DAC101C081 the address byte consists of 7 bits for the address and 1 bit for read or write.
With ADR0 grounded the address is 000 1101.
To write to the part you need to add a 0 to the end and so you send 0001 1010 (0x1A) for the address byte. See Figure 26 in the datasheet.
To read from the part you need to add a 1 to the end and so you send 0001 1011 (0x1B) for the address byte. See Figure 27 in the datasheet.
i2c驱动我也分享下,参考24c04类似代码
//#define ADDR_IIC 0x0d #define ADDR_IIC 0x0c /* enum ENUM_TWI_REPLY { TWI_NACK=0 ,TWI_ACK=1 }; */ enum ENUM_TWI_BUS_STATE { TWI_READY=0 ,TWI_BUS_BUSY=1 ,TWI_BUS_ERROR=2 }; static void delay_nop(uint8_t time) { uint8_t i; for(i=0; i<time; i++) { __nop(); __nop(); } } static void TWI_delay(void) { uint8_t i=5; //i=10延时1.5us//这里可以优化速度 ,经测试最低到5还能写入 while(i--); } void DAC081_Set(void) { } uint8_t TWI_Start(void) { SDAH; SCLH; TWI_delay(); if(!SDAread)return TWI_BUS_BUSY; //SDA线为低电平则总线忙,退出 SDAL; TWI_delay(); if(SDAread) return TWI_BUS_ERROR; //SDA线为高电平则总线出错,退出 SCLL; TWI_delay(); return TWI_READY; } void TWI_Stop(void) { SDAL; SCLL; TWI_delay(); SCLH; TWI_delay(); SDAH; TWI_delay(); } void TWI_Ack(void) { SCLL; TWI_delay(); SDAL; TWI_delay(); SCLH; TWI_delay(); SCLL; TWI_delay(); } void TWI_NoAck(void) { SCLL; TWI_delay(); SDAH; TWI_delay(); SCLH; TWI_delay(); SCLL; TWI_delay(); } uint8_t TWI_WaitAck(void) //返回为:=1有ACK,=0无ACK { SCLL; TWI_delay(); //SDAH; GPIO_PinModeSet(gpioPortE, 13, gpioModeInput, 0); //TWI_delay(); SCLH; TWI_delay(); if(SDAread) { SCLL; return 0; } SCLL; GPIO_PinModeSet(gpioPortE, 13, gpioModePushPull, 1); return 1; } void TWI_SendByte(uint8_t SendByte) //数据从高位到低位// { uint8_t i; for(i=0; i<8; i++) { SCLL; TWI_delay(); if(SendByte&0x80) SDAH; else SDAL; SendByte<<=1; //TWI_delay(); SCLH; TWI_delay(); } SCLL; } uint8_t DAC081_WriteByte(uint8_t upper) { uint8_t i; TWI_Start(); TWI_SendByte( (ADDR_IIC<<1) & 0xFE);//写器件地址 写入:地址最低位是0,读取:地址最低位是1 //TWI_SendByte( 0x1A); if(!TWI_WaitAck()) { TWI_Stop(); return 0; } TWI_SendByte((upper>>4)&0x0F); TWI_WaitAck(); TWI_SendByte(upper<<4); TWI_WaitAck(); TWI_Stop(); return 0; }