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.
Tool/software: Code Composer Studio
Host cpu and msp430 connect with IIC about 50khz speed. msp430 firmware version is 00.01.36.00. Host cpu cannot get correct data. Is there a minimum limit on iic speed? The IIC speed is about 300Khz between PSE_System_Firmware_GUI_1.0.0 running on pc and msp430.
The following is our read and write code:
/*read msp430*/
int poe_i2c_read(unsigned char theSlave, unsigned char *buf, int len)
{
int error, cntr = 3;
int i;
do {
error = 0;
/*
* generate start condition
*/
i2c_start();
/*
* send slave address
*/
i2c_outbyte(theSlave | 0x01);
/*
* wait for ack
*/
if(!i2c_getack())
error = 1;
for(i = 0; i < len; i ++)
{
/*
* fetch buf
*/
buf[i] = i2c_inbyte();
/*读最后一个字节后发送NACK*/
if(i < len - 1)
i2c_sendack();
else
i2c_sendnack();
}
/*
* end sequence
*/
i2c_stop();
} while(error && cntr--);
return -error;
}
/*write msp430*/
int poe_i2c_write(unsigned char theSlave, unsigned char *buf, int len)
{
int error, cntr = 3;
int i;
do {
error = 0;
i2c_start();
/*
* send slave address
*/
i2c_outbyte((theSlave & 0xfe));
/*
* wait for ack
*/
if(!i2c_getack())
error = 1;
/*
* send buf
*/
for(i = 0; i < len; i ++)
{
i2c_outbyte(buf[i]);
/*
* now it's time to wait for ack
*/
if(!i2c_getack())
error |= 2;
}
/*
* end byte stream
*/
i2c_stop();
} while(error && cntr--);
i2c_delay(clock_low_time);
return -error;
}
Hi,I2C standard mode up to 100 kbps and fast mode up to 400 kbps support on MSP430 device. There is no minimum speed limit. On I2C communication code, please refer to the code example and driver library on https://dev.ti.com/tirex.
Hi, Our host cpu use GPIO to simulate IIC. There is some problem with the IIC communication between Host CPU and MSP430.
I'm not familiar with this code, but a common oversight in software-I2C (master) implementations is clock-stretching. The MSP430 I2C unit uses clock-stretching routinely.
**Attention** This is a public forum