Jump to content
vineelachandra

i2c communication not working on msp430fr5969 rev 2.0

Recommended Posts

I just ran a quick test with the Sketch below. This is using MSP430 core version 1.0.3. Note that as per pinmap I2C lines, by default, are on pins 9 (SCL) and 10 (SDA) http://energia.nu/pinmaps/msp-exp430fr5969/. Also make sure that you have GND connected from the device to the LaunchPad.

What type of device are you trying to talk to?

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(115200);  // start serial for output
}

uint16_t x = 0;

void loop()
{
  /* Read from device #2 */
  Wire.requestFrom(2, 6);    // request 6 bytes from slave device #2

  while(Wire.available())    // slave may send less than requested
  { 
    char c = Wire.read();    // receive a byte as character
    Serial.print(c);         // print the character
  }
  Serial.println();

  /* Write to device #2 */
  Wire.beginTransmission(2);  // transmit to device #2
  Wire.write("x is ");        // sends five bytes
  Wire.write(x);              // sends one byte  
  Wire.endTransmission();     // stop transmitting
  
  x++;
  
  delay(500);
}

 

Share this post


Link to post
Share on other sites

Thank you for the response.

I m trying msp430 to talk to arduino uno.When msp430fr5969 is configured as master..it is working but when i make it slave (I used example codes)..communication is not happening between the two.

Share this post


Link to post
Share on other sites

I spaced out on this. Tank you to one of the developers for reminding me. The msp430fr5969 does not have hardware I2C on pins 9/10 and thus no I2C slave on those pins, only software master. It does however have both hardware slave/master on pins 14(SCL)/15(SDA). This module can be activated by calling Wire.setModule(0) before Wire.begin(). Please see Sketch below as an example:

 

#include <Wire.h>

void setup()
{
  Wire.setModule(0);
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(115200);         // start serial for output
}

void loop()
{
  delay(100);
}

void receiveEvent(int howMany)
{
  while(1 < Wire.available()) // loop through all but the last
  {
    char c = Wire.read();     // receive byte as a character
    Serial.print(c);          // print the character
  }
  int x = Wire.read();        // receive byte as an integer
  Serial.println(x);          // print the integer
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...