Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic/MSP430 - I2C Issue after using SPI #17

Closed
tinyos-issues opened this issue Dec 21, 2012 · 4 comments
Closed

Epic/MSP430 - I2C Issue after using SPI #17

tinyos-issues opened this issue Dec 21, 2012 · 4 comments

Comments

@tinyos-issues
Copy link
Member

Original author: brad...@gmail.com (February 04, 2011 18:09:32)

What steps will reproduce the problem?

Try to use I2C after using the SPI0 module on the TI MSP430.

In TinyOS:
call HplUsart.enableSpi(); // Usart0
call HplUsart.disableSpi();
call HplI2C.setModeI2C();

What is the expected output? What do you see instead?
I2C commands should work. Instead, with a write() the address is sent correctly, but the actual data isn't put on the wires. The I2C write() never finishes and doesn't signal writeDone().

What version of the product are you using? On what operating system?
Latest SVN on Ubuntu.

Please provide any additional information below.
The fix I found was to clear the I2CTCTL by setting it to 0x01 before configuring it properly. I don't think it has to be 0x01, necessarily, but I don't think just any value will work. I could not find this in the MSP430 documentation or the errata sheet.

$ svn diff HplMsp430I2C0P.nc

Index: HplMsp430I2C0P.nc

--- HplMsp430I2C0P.nc (revision 5326)
+++ HplMsp430I2C0P.nc (working copy)
@@ -81,6 +81,8 @@
U0CTL &= ~I2CEN;

   U0CTL = (config->i2cRegisters.uctl | (I2C | SYNC)) & ~I2CEN;
  •  I2CTCTL = 0x01;  // resetting I2CTCTL first,
    
  •                   // before configuring it,
    
  •                   // for some reason causes the I2C module to +                       // work after SPI has been used
    
    I2CTCTL = config->i2cRegisters.i2ctctl;
    I2CPSC = config->i2cRegisters.i2cpsc;

Original issue: http://code.google.com/p/tinyos-main/issues/detail?id=14

@tinyos-issues
Copy link
Member Author

From vlado.handziski on February 16, 2011 14:18:11
Hi,

Can you provide a bit more info on the platform that you are using, i.e. which epoc core design and what devices are attached to the port? Switching between SPI and I2C has always been very tricky on the 1611, and the errata is full with I2C issues.

If the I2CEN was not disabled, your proposed change would effectively send a START condition. Did you check if the I2CSTT is indeed the culprit? I.e. did all successful modifications of I2CTCTL include a set I2CSTT? I wonder if this is again some timing issue or the internal I2C state machine somehow gets confused by the previous SPI signaling...

Vlado

@tinyos-issues
Copy link
Member Author

From brad...@gmail.com on February 17, 2011 23:48:56
No problem. The Epic core version I'm using is the 11-28-2007 version that has the flash and radio on the same bus. The only I2C device on the I2C bus is my light sensor, a Rohm BH1721FVC. I'm using a new board that I created, and I have attached the schematic.

I know that setting I2CTCTL to the particular value 0x01 isn't required, and that that value wasn't chosen because of the I2CSTT bit. I believe writing 0x00 will work. I tried some variations to determine if the value mattered, and I think I found some that didn't work (closer to 0xFF), but I didn't try too hard. After looking at the errata sheet it does seem that just writing I2CTCTL resets the I2C state machine which takes care of the problem, but I don't know for sure.

Brad

PS. The origin of writing 0x01 is because the U0TCTL register is reset to 0x01, and I found the U0TCTL register as the problem before I realized it was the same as I2CTCTL.

@tinyos-issues
Copy link
Member Author

From vlado.handziski on March 12, 2011 00:40:06
Patch applied as temp. fix in rev 5508. I still can not recreate the problem on my hw though.

Vlado

@tinyos-issues
Copy link
Member Author

From brad...@gmail.com on August 12, 2011 08:07:16
Since I had this issue I've made more of the hemera boards and some have this problem and some don't. I have no idea why.

azeey pushed a commit to pillforge/tinyos that referenced this issue May 25, 2013
(fix) gnode, cc1101: Radio stack fixes.   CCA lockup
(fix) gnode, ccpacket: make sure space is available for timestamping (AckP)
(fix) gnode: update flash/SPI pins to support more flash pages
(fix) gnode: update platform init levels better naming.
(fix) gnode: define USER button.

(cosmetic) Add license to gnode files (standard TinyOS Intel license).
(cosmetic) comment mod, whitespace update, fix file modes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant