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.

Problem Recive I2C Hercules TMS570

Other Parts Discussed in Thread: HALCOGEN, TMP275

Hello, i am working with the Hercules and i can't read from I2C bus. 

I write the next code (previously i configured the device with HalCoGen 3.09.00):

void main(void)
{
/* USER CODE BEGIN (3) */

i2cInit();

//Config
i2cREG1 -> MDR |= I2C_TRANSMITTER;
i2cSetSlaveAdd(i2cREG1,0x48);
i2cSetCount(i2cREG1, 1);
i2cSetStop(i2cREG1);

//send
i2cSetStart(i2cREG1);
i2cSendByte(i2cREG1, 0x00);

//reconfig
i2cSetMode(i2cREG1,I2C_MASTER);
i2cREG1 -> MDR |= I2C_RECEIVER;
i2cSetSlaveAdd(i2cREG1,0x48);
i2cSetCount(i2cREG1, 1);
i2cSetStop(i2cREG1);

//recive
i2cSetStart(i2cREG1);
a=i2cReceiveByte(i2cREG1);

while(1)
{

}

/* USER CODE END */
}

When i send bytes the i2c works, but i try to receive i have problems. I saw the bit frame the device sends the direction and the R/W bit low and don't receive anything.

I'm trying to comunicate to TMP275 temperature sensor.

Thanks

  • Franco,

    We are looking at your problem and will be back to you as soon as possible.

  • Hello, i'm use the next code and i can send and resaive for separted, but when i try to use both not work.

    void main(void)
    {
    /* USER CODE BEGIN (3) */

    i2cInit();

    //Config
    i2cREG1 -> MDR |= I2C_TRANSMITTER;
    i2cSetSlaveAdd(i2cREG1,0x48);
    i2cSetCount(i2cREG1,2);
    i2cSetStop(i2cREG1);

    //send
    i2cSetStart(i2cREG1);
    i2cSendByte(i2cREG1, 0x01);
    i2cSendByte(i2cREG1, 0x77);

    i2cSetCount(i2cREG1,2);
    i2cSetStop(i2cREG1);
    i2cSetStart(i2cREG1);
    i2cSendByte(i2cREG1, 0x00);

    // reconfig


    // Disable I2C during configuration
    i2cREG1->MDR = 0;

    // Configure the I2C controller as receiver
    i2cREG1->CNT = 2;
    i2cREG1->MDR = I2C_RESET_OUT | I2C_START_COND | I2C_STOP_COND | I2C_MASTER;

    // Receive the data
    int a, b;

    i2cSetStart(i2cREG1);
    a=i2cReceiveByte(i2cREG1);
    b=i2cReceiveByte(i2cREG1);

    while(1)

    {

    }

    /* USER CODE END */
    }

  • Franco,

    Here is a test code that illustrates the few methods to Read and Write to an I2C EEPROM.
    This code is using HalcoGen driver.
    The I2C is configured as Master/Transmiter, the EEPROM is slave with an address = 0x50
    The Data Count is 8, Bit Count = 8_bit, add mode 7bit, no interrupt.

    Here is the 8206.sys_main.c

    Please have a look and let me know if this is helpful.

  • Hi,

    Unfortunatelly the read example based on the HalcoGen didn't work correct. The Register Read Address will not transfered over I2C to the device.

    There exist another example for the SingleByte Read Sequence and Burst Read Sequence who are well tested?

    Sincerely Roland

    //--------------------------------------------------------------------------------------------
    // RANDOM READ of 10 consecutive bytes
    //--------------------------------------------------------------------------------------------

    i2cSetCount(i2cREG1, 1);
    i2cREG1->MDR = i2cREG1->MDR | I2C_FREE_RUN | I2C_MASTER | I2C_TRANSMITTER;
    i2cSetStart(i2cREG1);
    i2cSendByte(i2cREG1, 0x00); // Read address

    i2cSetCount(i2cREG1, 10);
    i2cREG1->MDR = I2C_FREE_RUN | I2C_START_COND | I2C_STOP_COND |I2C_MASTER | I2C_RECEIVER | I2C_RESET_OUT | I2C_8_BIT;
    i2cReceive(i2cREG1,10,data_in);