Due to the U.S. Thanksgiving holiday, please expect delayed responses during the week of 11/22.

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.

LAUNCHXL2-RM46: I2C communication issue

Part Number: LAUNCHXL2-RM46
Other Parts Discussed in Thread: HALCOGEN

Hi, 

I am using RM46x Launchpad for development. We are interfacing Input Output expander as a slave device to RM46x, I am facing some issues in writing data bytes to slave device.

I have configured I2C using Halcogen API.

Halcogen Settings:

Global config- Enabled Master Mode

Add Mode- 7Bit_ AMODE

Tx/Rx- Transmitter

Bit Count- 8

Data Count- 12

I2C Clock:

Baud Rate- 100

I2C port- Pullups enabled

PINMUX:

Enabled I2C port

 

Driver Enable:

I2C driver enabled

Below is the I2C Transmitter part code:

 ///////////////////////////////////////////////////////////////
    //        Master Transfer Functionality                      //
    ///////////////////////////////////////////////////////////////
    /* I2C Init as per GUI
     *  Mode = Master - Transmitter
     *  baud rate = 100KHz
     *  Count = 10
     *  Bit Count = 8bit
     */
    i2cInit();

    /* Configure address of Slave to talk to */
    i2cSetSlaveAdd(i2cREG1, 0x80);
    /* Set direction to Transmitter */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
    /* Configure Data count */
    i2cSetCount(i2cREG1, 22);
    /* Set mode as Master */
    i2cSetMode(i2cREG1, I2C_MASTER);
    /* Set Stop after programmed Count */
    i2cSetStop(i2cREG1);
    /* Transmit Start Condition */
    i2cSetStart(i2cREG1);

 
    i2cSendByte(i2cREG1, 0x02);
    i2cSendByte(i2cREG1, 0x0F);
    
    i2cSendByte(i2cREG1, 0x09);
    i2cSendByte(i2cREG1, 0x55);
   
    i2cSendByte(i2cREG1, 0x0A);
    i2cSendByte(i2cREG1, 0x55);
   
    i2cSendByte(i2cREG1, 0x0B);
    i2cSendByte(i2cREG1, 0x00);
    i2cSendByte(i2cREG1, 0x0C);
    i2cSendByte(i2cREG1, 0x00);

continued...………...

 

Problem:

1. After sending 1st Command Byte, The I2CDXR value is copying to I2CDRR register and data remains remains in DRR register.

Loop back is disabled but I2CSTR-> AAS=1

I2C MDR: 0E20

2.I am unable to send more than 4 bytes of command/data, As soon as count reaches 4, unable to write further bytes.

After writing 4 Bytes: I2C Status Register (I2CSTR): value= 1E08, & it stop sending data

Currently I don't have logic Analyser or Oscilloscope to check with waveforms.

Kindly guide me further

Any suggestions will be highly appreciated

Thanks

Regards, 

Vishwas

  • Hello,

    Can you connect external pull-up resistor to I2C bus - for example 10k ? Also, check whether you are following the I/O expander protocol. It will be good to check bus with oscilloscope.

    You can ensure whether Slave sends ACK/NACK and then send multiple bytes by using the following:


    i2cSetStart(i2cREG1);

    i2cSendByte(i2cREG1, Write_Add);

    if((i2cREG1->STR & I2C_NACK) == 0)
    {
    i2cSend(i2cREG1, Count, tx_buff);
    }

  • Hello,

    Do you have progress with this?

  • Hi Miro,

    Thanks for the suggestion.

    Actually the problem was with the slave address. As it is 7 bit addressing I was supposed to right shift.

    Now its resolved.

    Best Regards,

    Vishwas

  • Hi Miro,

    I have one more issue with I2C communication.


        i2cInit();
        /* Configure address of Slave to talk to */
        i2cSetSlaveAdd(i2cREG1, SLAVE_WRADDRESS);
        /* Set direction to Transmitter */
        /* Note: Optional - It is done in Init */
        i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
        /* Configure Data count */
        i2cSetCount(i2cREG1, 2);
        /* Set mode as Master */
        i2cSetMode(i2cREG1, I2C_MASTER);
        /* Set Stop after programmed Count */
        i2cSetStop(i2cREG1);

        i2cSetStart(i2cREG1);
    After i2cSetStart function, the STT bit in MDR register should RESET, which was happening properly before. Now, The STT bits giving me trouble. It is not resetting after i2c start and I am unable to write data.  
    13 STT Start condition

    The start condition bit works with the STP bit (master only mode). The STT and STP bits are configured
    to generate different transfer formats (see Table 30-16). The STT and STP bits can be used to
    terminate the repeat mode. This bit takes one I2C module clock cycle to set.
    0 The STT is reset to 0 by the hardware after the START condition has been generated.
    1 STT is set to 1 by the device to generate a START condition. In master mode, setting STT to 1
    generates a START condition.
    Kindly help me what is wrong with it.
    Best Regards,
    Vishwas