关于TI DAC芯片 DAC101C081 地址选择

这个芯片资料非常简单,单纯看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;
}



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值