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.

CCS/MSP430F5234: about msp430

Part Number: MSP430F5234

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;
}

 

**Attention** This is a public forum