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: Interfacing VL6180x time of flight sensor with msp430g2553

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

Hi,

I am trying to interface VL6180x time of flight sensor  with msp430g2553.

Its an I2C sensor, I have connected SCL and SDA of sensor to P1.6 and P1.7 of msp430 respectively.

I am using energia IDE, Wire library and Vl6180x pololu library for communication.

Above are the setup, but I am not getting data from sensor to msp.

I have used this same library in energia to interface and test with CC3200, it works good. So the sensor and library are ok.

Pullup resistors for I2C are placed in sensor board itself.

Below is my energia code, the code compiles and dumps into msp without any error.

#include <Wire.h>
#include <VL6180X.h>

VL6180X sensor;

#define GLED P1_0///P2_2
#define RLED P2_1

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  pinMode(GLED,OUTPUT);
  pinMode(RLED,OUTPUT);
  digitalWrite(GLED,LOW);
  digitalWrite(RLED,LOW);
  
  digitalWrite(GLED,HIGH);
  delay(1000);
  digitalWrite(GLED,LOW);

  sensor.init();
  sensor.configureDefault();

  // Reduce range max convergence time and ALS integration
  // time to 30 ms and 50 ms, respectively, to allow 10 Hz
  // operation (as suggested by Table 6 ("Interleaved mode
  // limits (10 Hz operation)") in the datasheet).
  sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30);
  sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50);

  sensor.setTimeout(500);

   // stop continuous mode if already active
  sensor.stopContinuous();
  // in case stopContinuous() triggered a single-shot
  // measurement, wait for it to complete
  delay(300);
  // start interleaved continuous mode with period of 100 ms
  sensor.startInterleavedContinuous(100);

}

void loop()
{
  Serial.print("Ambient: ");
  Serial.print(sensor.readAmbientContinuous());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.print("\tRange: ");
  Serial.print(sensor.readRangeContinuousMillimeters());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
  if(sensor.readRangeContinuousMillimeters()>50){
    digitalWrite(RLED,HIGH);
    digitalWrite(GLED,LOW);
  }else{
    digitalWrite(RLED,LOW);
    digitalWrite(GLED,HIGH);    
  }

  Serial.println();
}

  • Hi Jan,

    Can you verify that the communication is working from sensor side and that you get the expected signals on SCL and SDA?

    Also, are you setting the MSP pins accordingly for I2C configuration?

    For more details on the MSP430 side of it I suggest for you to have a look at the Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430 MCUs Application Report. It gives some hints how to troubleshoot serial communication issues.

    Please have a look and provide some more details on your hardware in case those hints can't help to pin the problem down.

    Regards,

    Britta

  • Hi Britta,

    Yes, the sensor is communication is working and SCL & SDA are as expected.
    I am using the pins which is recommend in datasheet for I2C.
    Ok, I will look in the above link and post back.

    Thanks Britta

    Regards

    JanSom
  • Hi,

    do you have any update on the issue you saw before? Is it still occuring or were you able to solve it?
    Please let me know so I can take the according actions.

    Thanks and best regards,
    Britta
  • Hi Britta,

    I am have gone through docs and possible ways of error. I didn't get communication between sensor and controller yet. Are you sure ,we make communication through I2C on msp430g2553?

  • Hi,

    yes there is the USCI_B module on chip of MSP430G2553.

    The best way to troubleshoot if the hardware is working just fine would be to try out example code for the MSP430G2553 I2C module so that we can rule any issue in firmware. But my take is you do not use Code Composer Studio. Is that right? Otherwise please use the TI Resource Explorer in CCS, browse to Software -> MSP430Ware -> Devices -> MSP430G2xx ->MSP430G2553 -> Peripheral Examples -> Register Level and you'll see different examples staring with msp430g2xx3_uscib0_i2c_xx.c. You'll find examples code for both I2C master and slave.

    With regards to energia: Did you mak sure to user the proper pins for the Wire interface? Also, did you check the 7-bit vs. 8-bit I2C adresses? you might also want to check in the Official 43oh forum to ask if others also experienced this issue.

    Best regards,

    Britta

  • Hi Britta, thanks for your response. I am out of town for one week so I will try this after that and share the response.

    Regards
    JanSom
  • Hi JanSom,

    do you have any update on this issue yet? I know you've been out so please indicate if you need anymore support from my side or verify if any answer resolved your issue.
    I'll then go ahead and close this thread or otherwise keep helping to troubleshoot the exact issue.

    Thanks and best regards,
    Britta
  • Hi Britta,

    I have tried with CCS example on I2C, that doesn't work either. I switched to another controller to interface with this sensor.

    If you are interested I can share my code on that,may be it might be useful in future.

    Thanks for your response.

    Regards,

    JanSom

  • Hi JanSom,

    I'm sorry to hear that the CCS examples didn't solve the issue for you. I'd be happy to assist you on making those work but I take you switched to a different microcontroller.

    May I ask if you also mentioned in the energia forum that you had some issues using the code?

    If ok for you I'd go ahead and close this thread unless you have any open questions you'd like to ask.

    Thanks and best regards,

    Britta

  • Hi Britta,

    No, I have not mentioned this issue in Energia forum. This is my only post regarding this issue.
    Anyway you can close this issue, its been a great support from you Britta.

    Thanks

    JanSom

**Attention** This is a public forum