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.

MSP430 i2c interrupt



I have a connection between msp430 with a device by using I2C. The device will send a singal through I2C to msp430 inform the status condition. So i don't wan using polling method to check the signal all the time. Can i know is it can be using interrupt method when signal is send from the device to msp430? The sda and scl port is p3.1 and p3.2. Can i know the concept to making it work by the interrupt method, can explain more detail? 

  • As far as I can understand. You can do it.
    but usually, I2C slave has different pins which generate interrupt when ever data is ready from the slave device.
    for example Lis3DH is an accelerometer. Its has 2 interrupt pins SDA, SCL PWR and Ground pins. You interface SCl to SCL of MSP and SDA to SDA of MSP.  Then Interrupt pins of Lis3DH goes to port pins of MSP430. 

    When ever accelerometer data is ready, an interrupt is generated in this interrupt of slave and MSP detects this. Upon detection you will read corresponding register of Accelerometer via I2c and get the data. 

    if you need a example code for this kind try searching I2c sample code for reading accelerometer in this forum or google. if u  r not successful give me a buzz i will give u one.

  • I2C is a master-slave protocol. Usually, the device is a slave, so it won’t send anything to the master (the MSP) if the master isn’t asking for it.
    There is no way for a slave to tell the master (unrequested) that is has something to report. At least not through I2C.
    Some slave provide a separate signal that can be connected to a GPIO pin of the master (perhaps one with interrupt capability) and tell the master that an operation has finished or new data has arrived. Then the master can request this through I2C. This signaling, however, has nothing to do with I2C.

    None of the synchronous protocols (I2C, SPI) allows the slave to start a transfer on its own. Even though I2C allows the slave to stall a transfer by holding the clock line low. But only after being addressed by the master.

  • If initially set the MSP430 i2c to slave (receive signal) and connect to other device which is master (sending signal). How to enable the interrupt process when master sending signal to slave. If the master signal is example like this ( Start condition > adress > r/w > ack > data >ack > data > ack > Stop condition ). 

    May i know the concept  to trigger the interrupt only when the signal send to MSP430 instead of continue looping to check for the signal? What the simple c programming to make it work like initialize and the interrupt routine? Is it need to initialize the condition such as ( Enable UCSTTIE start condition bit in UCBxI2CIE ) so the interrupt will be trigger whenever the start condition signal send from mater device to MSP430. The port for I2C is P3.1 and P3.2. 

  • If the MSP is running as slave and the external device is master, then yes, set-up the MSP for slave operation and enable the start byte received interrupt. It will tell you that your slave has been selected. In the ISR, you then have to decide whether to send a NACK (and refuse the connection) or an ACK. In the latter case, check the UCTR bit whether it is a send or receive request, and in case of a send request, write the data you want to send to TXBUF. In case of a receive, enable the RX interrupt and wait for the data coming.

**Attention** This is a public forum