检索网络找到3个版本的驱动,关于8591读取函数
版本1
//------------------------------------------------------------------------------
// 模块功能:接收一个AD转换数据
// 模块函数名:Read_AD_one(unsigned char addrss)
// 模块功能:先寻址后发送AD转换控制(通道一:0x41;通道二:0x42;),改发送
// 为接收状态,等待数据接收成功为止。
//------------------------------------------------------------------------------
void Read_DA_one(unsigned char control)
{
// UCB0CTL1 |= UCTR; //发送模式(在数据准备好的时候用配合开始条件)
IE2 |= UCB0TXIE;
TxData[0]=control;
PTxData = (unsigned char *)TxData; // TX array start address
TXByteCtr = 1; // Load TX byte counter
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
__bis_SR_register(CPUOFF + GIE);
IE2 |= UCB0RXIE;
UCB0CTL1 &= ~UCTR; //接收模式
UCB0CTL1 |= UCTXSTT;
while (UCB0CTL1 & UCTXSTT);
__bis_SR_register(CPUOFF + GIE);
}
版本2
void I2C_ReadData(unsigned char address)
{
UCB0CTL1 |= UCTR ;
UCB0CTL1 |= UCTXSTT; // I2C TX, start condition
UCB0TXBUF = address; //eeprom low addr
while((IFG2 & UCB0TXIFG)==0);
UCB0CTL1 &= ~UCTR; // I2C RX,
UCB0CTL1 |= UCTXSTT;
while(UCB0CTL1&UCTXSTT);
UCB0CTL1 |= UCTXSTP;
while((IFG2&UCB0RXIFG)==0);
RX_Data = UCB0RXBUF;
while(UCB0CTL1 & UCTXSTP);
}
版本3
uchar c_AdcRead()
{
uchar _data;
_data = IIC_RecByte();
IIC_SendAck(0);
if(_data == 128)
channel = -1;
else
channel = (channel + 1)%4;
return _data;
}
我想通过版本2去读adc1的数值,读的地址0x91,子地址041,我直接调用无法读出数据 这样I2C_ReadData(0x91),
应该如何修改呢
|