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.

MSP430G2553: To MSP430G2553 I2C link

Part Number: MSP430G2553
Other Parts Discussed in Thread: ENERGIA, , MSP430WARE

Problem connecting Master MSP430 to Slave MSP430 via I2C.  Using ENERGIA 17 code examples.  Have updated twi.c and twi.swh  .( Code works on ARDUINO devices )

Ran program to return addresses of connected devices - all addresses from 0 to 127 were returned in a loop - How does MSP recognise itself as a Slave device ?  Or are there other issues ?

Thanks

Brian Elliott  

  • Hi Brian,

    Has the slave MSP430G2553 device been programmed to respond to the I2C messages accordingly? Are you using pull-up resistors on the I2C lines?

    Regards,

    James

    MSP Customer Applications
  • brian elliott said:

    Ran program to return addresses of connected devices - all addresses from 0 to 127 were returned in a loop - How does MSP recognise itself as a Slave device ?  Or are there other issues ?

    >

    To answer your first question, the slave recognizes itself as a slave device when the UCMST bit is 0. It should automatically be configured properly if you've flashed the slave with the correct firmware.

  • The code below works on ARDUINO UNO / NANO combination.

    [ On advice from 430h Forum I used ' revised ' twi.c and twi.sw.c files as supplied ( via e2e link : from ROBERT WESSELS TI EMPLOYEE )

    LINK :-

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/529036/1924562#1924562

    Below were obtained from Youtube video :- ]

    MASTER :-

    #include <Wire.h>
    #define LED RED_LED
    void setup()
    {
    Wire.begin(); // join i2c bus (address optional for master)
    delay(2000);
    pinMode(LED, OUTPUT);
    }



    void loop()
    {
    Wire.beginTransmission(4); // transmit to device #4

    Wire.write('H'); // sends one byte
    Wire.endTransmission(); // stop transmitting
    delay(3000);
    digitalWrite(LED, HIGH);


    delay(1000);
    Wire.beginTransmission(4); // transmit to device #4

    Wire.write('L'); // sends one byte
    Wire.endTransmission(); // stop transmitting
    delay(3000);
    digitalWrite(LED, LOW);
    delay(1000);
    }

    SLAVE :-

    #include <Wire.h>
    #define LED RED_LED
    void setup()
    {
    Wire.begin(4); // join i2c bus with address #4
    Wire.onReceive(receiveEvent); // register event
    // Serial.begin(9600); // start serial for output
    }

    void loop()
    {
    // delay(100);
    }

    // function that executes whenever data is received from master
    // this function is registered as an event, see setup()
    void receiveEvent(int howMany)

    {
    // delay(100);
    digitalWrite(LED,HIGH);
    delay(1000);
    digitalWrite(LED,LOW);
    delay(1000);

    while(Wire.available()) // loop
    {
    char c = Wire.read(); // receive byte as a character
    Serial.print(c); // print the character
    if( c =='H')
    {
    digitalWrite(LED,HIGH);
    delay(1000);
    }
    else if ( c =='L')
    {
    digitalWrite(LED,LOW);
    delay(1000);

    }
    }
    }

    I also ran this :-

    #include <Wire.h>

    void setup()
    {
      Serial.begin(9600);
      Serial.println("Start!");
      
      Wire.setModule(0);
      Wire.begin();
    }

    void loop()
    {
      findAddress();
      delay(1000);
    }

    uint8_t fromAddress = 0;
    uint8_t toAddress = 127;

    void findAddress()
    {
      for (uint8_t a = fromAddress; a < toAddress; a++)
      {
        Wire.beginTransmission(a);
        int endStatus = Wire.endTransmission();

        if (endStatus == 0)
        {
          Serial.print("Found device at: 0x");
          Serial.println(a, HEX);
        }
      }
    }

    This produced a loop of all addresses from 0 to 127.

    Note Wire.setModule (0) crashes program !

    Any suggestions - are delays too large for MSP430 ?

    Regards

    B. Elliott
  • PS Pull-ups are 4k7 , common ground used. Green LED link removed.
  • While the following app note is older, it still has some good discussion about something similar to what you're wanting to do.

    Using the USCI I2C Slave

    Also, as Caleb mentioned in one of your other threads, we offer many code examples in MSP430Ware for I2C (they're named 'msp430g2xx3_uscib0_i2c_xx.c'). Recently, he has written an excellent app note that may also help you now and in the future.

    Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430™ MCUs

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum