This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:Code Composer Studio
主机 CPU 和 MSP430以 IIC 连接、速度约为50kHz。 MSP430固件版本为00.01.36.00。 主机 CPU 无法获取正确的数据。 IIC 速度是否有最低限制? PC 和 MSP430上运行的 PSE_System_Firmware_GUI_1.0.0之间的 IIC 速度约为300kHz。
以下是我们的读取和写入代码:
/*读取 MSP430*/
int poe_i2c_read (unsigned char theSlave、unsigned char * buf、int len)
{
int 错误、cntr = 3;
int i;
执行{
误差= 0;
/*
*生成起始条件
*
I2C_start();
/*
*发送从地址
*
I2C_outbyte (从器件| 0x01);
/*
*等待 ACK
*
if (!i2c_getack())
误差= 1;
for (i = 0;i < len;i ++)
{
/*
*获取 buf
*
buf[i]= i2c_inbyte ();
/*读最后一个字节后发送NACK */
if (i < len - 1)
i2C_sendack();
其他
i2C_sendnack();
}
/*
*结束序列
*
I2C_STOP();
} while (error && cntr --);
return -error;
}
/*写入 MSP430*/
int poe_i2c_write (unsigned char theSlave、unsigned char * buf、int len)
{
int 错误、cntr = 3;
int i;
执行{
误差= 0;
I2C_start();
/*
*发送从地址
*
I2C_outbyte ((Slave & 0xFE));
/*
*等待 ACK
*
if (!i2c_getack())
误差= 1;
/*
*发送 buf
*
for (i = 0;i < len;i ++)
{
I2C_outbyte (buf[i]);
/*
*现在是等待 ACK 的时候了
*
if (!i2c_getack())
错误|= 2;
}
/*
*结束字节流
*
I2C_STOP();
} while (error && cntr --);
I2C_DELAY (CLOCK_LOW_TIME);
return -error;
}
在 MSP430器件上支持高达100kbps 的 I2C 标准模式和高达400kbps 的快速模式。 没有最低速度限制。 有关 I2C 通信代码、请参阅 https://dev.ti.com/tirex 上的代码示例和驱动程序库。
大家好、我们的主机 CPU 使用 GPIO 来模拟 IIC。 主机 CPU 和 MSP430之间的 IIC 通信存在一些问题。
我不熟悉此代码、但在软件 I2C (主器件)实现中、通常需要进行的监督是时钟扩展。 MSP430 I2C 单元例行使用时钟扩展。