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