TI中文支持网
TI专业的中文技术问题搜集分享网站

TCA6416A 从机地址是多少?读写位怎么处理?

我看官方提供的430操作该器件发送的从机地址是7位(0x20)

/************************** I2C Address ***************************************/
#define TCA6416A_ADDRESS		0x20 		// I2C Address 0100 00 + ADDR + R/W
											// ADDR tied to P2.2 of LaunchPad
/************************** I2C Registers *************************************/

然后

// ****************************************************************************
//! @fnvoid TCA6416AInitI2CReg(TCA6416ARegs* Regs)
//! @brief
//!
//! TODOImplement I2C return (success/failure)
// ****************************************************************************
unsigned char TCA6416AInitI2CReg(TCA6416ARegs* Regs){
	unsigned char return_Value = I2C_OPERATION_SUCCESSFUL;
	I2C_Write(2, TCA6416A_ADDRESS, TCA6416A_CONFIG_REG0, (unsigned char*)&Regs->Config, 0);
	I2C_Write(2, TCA6416A_ADDRESS, TCA6416A_OUTPUT_REG0, (unsigned char*)&Regs->Output, 0);
	I2C_Write(2, TCA6416A_ADDRESS, TCA6416A_POLARITY_REG0, (unsigned char*)&Regs->PolarityInversion, 0);
	if(NACK)
	{
		NACK = 0;

		return_Value = I2C_OPERATION_FAIL;
	}

	return return_Value;
}

然后

void I2C_Write (unsigned char byte_Count, unsigned char Slave_Address, unsigned char Register_Address, unsigned char Register_Data[], unsigned char offset)
{// wait until I2C module has finished all operations.while (UCB0STAT & UCBUSY);// Set slave addressUCB0I2CSA  = Slave_Address;

	I2CBufferArray[byte_Count] = Register_Address;
	// If word mode, write 2 bytes
	int x = byte_Count-1;
	unsigned char y=0;
	for (;x>=0;x--)
	{
		I2CBufferArray[x] = Register_Data[y+offset];
		y++;
	}

	PtrTransmit = byte_Count;// start condition generationI2CWriteInit();// => I2C communication is startedUCB0CTL1 |= UCTXSTT;UCB0I2CIE |= UCNACKIE;// Enter LPM0 w/ interrupts
	__bis_SR_register(LPM0_bits + GIE);

	// I2C stop condition
	UCB0CTL1 |= UCTXSTP;

	// Ensure stop condition got sent
	while(UCB0CTL1 & UCTXSTP);UCB0I2CIE &= ~UCNACKIE;

}
UCB0I2CSA  = Slave_Address;
从上面这句话可以看出访问TCA6416A就是这个,那个R/W#位怎么使用的。

 
Kailyn Chen:

I2C Address格式就是后面注释部分,7位从机地址加一位读写位, 对于TCA6416A来说,为0100 00 + ADDR + R/W,ADDR 通过ADDR引脚的高低电平来决定,读写位为方向位,写为0,1为读。

yun xu2:

回复 Kailyn Chen:

嗯,谢谢,意思是说MSP430的知道的是7位从机地址,然后读写位是由430中某位寄存器决定,然后通过硬件自动加上去的。如果我模拟IIC的话就需要直接发送8位地址。

user4349101:

回复 Kailyn Chen:

不应该是0x40吗?

赞(0)
未经允许不得转载:TI中文支持网 » TCA6416A 从机地址是多少?读写位怎么处理?
分享到: 更多 (0)