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.

Software I2C Slave implementation example (i.e., bit banging) for MSP430

Other Parts Discussed in Thread: MSP430F5310

Hello,

  I am searching for an example of an I2C Slave, in C, software implementation (i.e., not using the hardware) for an MSP430F5310.  I found one example, SLAA330, that shows a software implementation of I2C for a slave, but it is in assembly.  The reasoning is that I am talking on an SMBus with multiple slaves (e.g., MSP430s) and I need to detect arbitration lose which is not possible within the MSP430 hardware.  I have read that some people use a combination of switching the MSP430 back and forth from slave to master, but this might be problematic making sure the clocks are aligned and following the proper protocol of the ack/nacks/start/stop bits.  

  So, I am hoping that someone knows of a I2C slave software implementation that my google-fu search was not able to find.

Thanks,

Mark

  • The MSP430 hardware does have the arbitration lost interrupt flag (UCALIFG).
  • Clemens, yes, the MSP430F5310 does have arbitration support, but only for master.  This is from the user guide, "If two or more master transmitters simultaneously start a transmission on the bus, an arbitration procedure is invoked".  As far as I know and a TI rep stated as much, the arbitration detection would not happen during the phase when two or more slaves are sending data and there is a conflict.  I have seen as much, which prompted my question to TI.  So, I am now forced to try and implement this in software.  I should be able to struggle developing one, but I am under a bit of a schedule crunch, so I was hoping one existed, someone might know of it, and could share.

  • Sorry, I did not see that you mentioned SMBus. (The I²C specfication defines arbitration only for transmissions made by a master, and requires slave addresses to be unique.)

    TI's SMBus Library uses driverlib, i.e., the I²C hardware.

    slaa073 has a software implementation of SMBus, but without slave arbitration, and in assembler. You could use it as a starting point to write your own implementation.

**Attention** This is a public forum