iragdoll 0 Posted November 14, 2010 Share Posted November 14, 2010 Does anyone know how to communicate between LaunchPads using I2C Communication? I would like to have a master unit connected to many slave units. The master unit will most likely be a computer, but I would like to simulate the master as a LaunchPad or Arduino microcontroller. The slave units must all be LaunchPads. Which pins do I use for I2C communication? Any code examples? Do I need pull-up resistors? Any help will be much appreciated! Quote Link to post Share on other sites
bluehash 1,581 Posted November 14, 2010 Share Posted November 14, 2010 I think I just answered you via the TI-Launchpad group. Quoting it here: Cde connected a port expander to the Launchpad via I2C His project is here. Remember to thank him if this works for you Quote Link to post Share on other sites
cde 334 Posted November 14, 2010 Share Posted November 14, 2010 Yea, the I2C Explorer has a bus-pirate like way of communicating from a pc through the uart to an i2c bus. It uses the builtin USI of the msp430G2231 to handle receiving and transmitting. It is nearly exactly what the TI description of how to use the USI for I2C master shows, put in C code. MSP430 Family Guide with USI description (PDF Page 449): http://focus.ti.com/lit/ug/slau144e/slau144e.pdf What you want is USI Slave though. It does not implement that. TI has great USI Slave examples that run on the msp430g line (I have not personally tried them). TI also has a precreated I2C USI code library in assembly, for both master and slave operation, which I would assume is a higher order more optimized than mine http://focus.ti.com/general/docs/litabs ... r=slaa368a The pdf explains how it is used, functions and all, while the zip has the actual library. Additionally, you can use a software i2c slave, not using the builtin USI peripheral. Based on a msp430f2131, which has 8kb, so I'm not sure it will run on a valueline part: http://www.ti.com/sc/docs/psheets/abstr ... laa330.htm Again, PDF for code examples, and zip for actual code. I'd go with using the USI instead of bitbanging it. The USI is better, it handles open drain pins, and it can deal with clock stretching. There is also a way to implement a SMBus Master or Slave on the msp430: http://www.ti.com/litv/pdf/slaa073 SMBus is basically i2c v1.1. Finally, there are full examples that can run on the msp430g valueline chips. http://www.ti.com/litv/zip/slac080h It is the MSP430F20xx, MSP430G2xx Code Examples (Rev. H) The ones you want to look at are (Depending on if you Use C or Assembly) USI 06-16. Show how to implement USI based I2C Masters and Slaves, for single and multi-byte usage. One even shows how to emulate an i2c eeprom. TLDR: Read the Code examples in http://www.ti.com/litv/zip/slac080h Or consider using the TI USI i2c Code Library http://focus.ti.com/general/docs/litabs ... r=slaa368a bluehash and gatesphere 2 Quote Link to post Share on other sites
JMLB 24 Posted November 15, 2010 Share Posted November 15, 2010 Make sure you have a common ground too. My first serial project was not working because I did not have common ground between my 2 chips Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 Hey guys, After looking through TI's code for some time, I still cannot come up with a solution. I need help with the coding and if anyone can send me an example on how to send the value "1" when you press the pushbutton connected to P1.3. I can figure out the master part but I just need help with the slave. Please anyone who can help me with this, I am still a beginner with the LaunchPad. Thanks! Quote Link to post Share on other sites
bluehash 1,581 Posted November 21, 2010 Share Posted November 21, 2010 Do you just want to detect if the pin goes high? or you want to transfer the value 1 from slave to master via I2C Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 I want to send the information from slave to master. The master also has to be able to send data to the slave. Quote Link to post Share on other sites
bluehash 1,581 Posted November 21, 2010 Share Posted November 21, 2010 You will have to do this in steps. 1. Are you sure if your master is working correctly? If so, how?. The best way to test this is test it with a standard I2C sensor like a battery gauge or compass. 2. For the slave...did you look through TI's document. Quote Link to post Share on other sites
bluehash 1,581 Posted November 21, 2010 Share Posted November 21, 2010 The above link has code is assembly. Thisone is in C Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 Okay i was just looking through the documentation and sort of understand it. I might come back and ask you some questions regarding it though. Where are the header and source files for it? Thanks! Quote Link to post Share on other sites
bluehash 1,581 Posted November 21, 2010 Share Posted November 21, 2010 Using the USCI I2C Slave Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 For some weird reason, it is not compiling. I added the header file into the include folder under ccsv4, but it says some of the timer functions are undeclared. Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 It says that it cannot build the .out file. Can you try the project yourself and see if it works for you? And then you can sort of help me step by step? Sorry that I am a beginner and do not grasp this very quickly... Thanks for Everything! Quote Link to post Share on other sites
bluehash 1,581 Posted November 21, 2010 Share Posted November 21, 2010 Thats because it is for the MSP430F2618 chip. You need to port it to the one you are using. If you select the above chip when you set up the project, it should compile. What you can do is use the TI code as an example and then build yours. I'm guessing you have the 2231. You will have to understand the code to do this. Copying code will not work. If you don't understand parts of the code, ask us. Quote Link to post Share on other sites
iragdoll 0 Posted November 21, 2010 Author Share Posted November 21, 2010 After I specified my device which is the MSP430G2231, it still says that -- "CALBC1_16MHZ is undefined" -- Any ideas? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.