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.

TMS570LC4357: i2C interruptions

Part Number: TMS570LC4357

Hello, 

I have a system, based on the I2C protocol, in which the TMS570LC4357 micro is acting as a slave. Now, depending on some user inputs, the master might want to send information to the slave (the TMS570LC4357 micro) at some point. In the meantime, the slave has to perform other tasks.

I am capable to send data and receive data with the master using i2cReceive and i2cSend when no interruptions are enabled. However, how can I set the slave to send data to the Master when I do not know when it is going to ask for it?

Checking the i2c interruptions in the reference manual, I do not see any type that could help me to solve this issue. I attach them here for commodity.

  • Hello,

    Slave mode is somewhat easier than master mode. You need to define a slave address for your device and write this address to I2COAR register. The slave address is an arbitrary but unique 7-bit number.

    The slave starts in receiver mode. When the master has written a byte, you get an RXRDY interrupt. Your interrupt handler must read that byte from I2CDRR. When the master wants to read a byte, you get a TXRDY interrupt. Your interrupt handler must write a byte to I2CDDR.

    The slave enters the transmitter mode when the slave address is the same as its OAR and R/nW bit is 1 (from master). you get a TXRDY interrupt. Your interrupt handler must write a byte to I2CDDR.

    As a slave, you have no control over what the master does; you must react to any write and read requests at any time.

  • Thank you for your response QJ. It was very helpful. I still have one final doubt though.

    In my current code the TMS570LC4357 micro is the slave. Sometimes it has to send data to the master and other times it has to receive data from it. I have implemented this in such a way that the slave is always "listening" to the Master (by i2cReceive) and when the master sends a specific command it makes the slave send data to the master (using i2cReceive). After the transmission is complete, the slave comes back to the listening mode. Everyhting is implemented within the i2cNotification handler.

    I am wondering if there is a better way to implement this.

    Thank you for your time. Best regards

  • I am not sure if there is better way or not. This is the way I used for testing.