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/TMS570LS1227: I2C-Communication with interrupts

Part Number: TMS570LS1227
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hi

Is there any example project for I2C-Communication with interrupts in master mode (I'm working with a TMS570LS12x and HALCoGen)?
At the moment I use the I2C communication interface in polling mode. It works, but sometimes I have problems with the blocking-loops in the send function (while ((i2c->STR & (uint32)I2C_TX_INT) == 0U)) and in the receive function (while ((i2c->STR & (uint32)I2C_RX_INT) == 0U)). I don't like this loops and would like to change to interrupt mode. An example would be very helpful for me.

Thanks, and best regards

 

Simon

  • Hello Simon,

    1. Enable I2C interrupt: channel 66 in VIM

    2. Enable the I2C RX interrupt (ICRRDY)

    3. The example is to use loopback mode for testing:

    void main(void)

    {

        uint32 buf_size = bsize;

        uint8  *t_buff = &TX_PACK[0];

        uint8  *r_buff = &RX_PACK[0];

        _enable_interrupt_();

        i2cInit();                       

        i2cSetOwnAdd(i2cREG1,own_add);  

        i2cEnableLoopback(i2cREG1);     

        i2cReceive(i2cREG1, 16, r_buff);

        i2cSetStart(i2cREG1);

        while(buf_size--)

        {

           i2cSendByte(i2cREG1,*t_buff++);       

        }

        i2cClearSCD(i2cREG1);

        i2cDisableNotification(i2cREG1, I2C_RX_INT);

        while(1);                        

    }

    Regards,

    QJ

    uint8  TX_PACK[bsize]={'H','E','R','C','U','L','E','S','M','I','C','R','O','-','T','I'};
    uint8  RX_PACK[bsize]={0};
    uint32 data;
     
    void main(void)
    {
        uint32 buf_size = bsize;
        uint8  *t_buff = &TX_PACK[0];
        uint8  *r_buff = &RX_PACK[0];
        _enable_interrupt_();
        i2cInit();                      
        i2cSetOwnAdd(i2cREG1,own_add); 
        i2cEnableLoopback(i2cREG1);    
        i2cReceive(i2cREG1, 16, r_buff);
        i2cSetStart(i2cREG1);
        while(buf_size--)
        {
           i2cSendByte(i2cREG1,*t_buff++);      
        }
        i2cClearSCD(i2cREG1);
        i2cDisableNotification(i2cREG1, I2C_RX_INT);
        while(1);                       
    }
  • Hello Simon,

    Please have a look at this thread and the final confirmed answer with attached working code for I2C in interrupt mode of operation.