Jump to content
43oh

Recommended Posts

I have been trying to use a simple I2C sensor (LM75) with a MSP430FR5994. I find there are two pin maps. One at Energia (http://energia.nu/wordpress/wp-content/uploads/2016/11/Capture-2016-11-30-à-15.10.44.png) and one at TI directly (http://www.ti.com/lit/ml/slau677/slau677.pdf) on page 2. I have tried using I2C (1) as indicated at in the TI reference, and I have tried I2C (2) as indiicated in the Energia reference. neither one work. I can use an Arduino to access the sensor so I have some hope that this might work. What pins do I need to use to use I2C? Is there a library call to specify which I2C pins to use?

By the way, I can connect to the board and load the blink sample, and I can do serial communication, so board connectivity is OK, I2C is not.

Gerald

Link to post
Share on other sites

I did not have Wire.setModule(0); (or 1)

THanks to Rei Vilo for pointing out "setModule".

The code works now:

 


// This example code is in the public domain.


#include <Wire.h>

void setup()
{
  Wire.setModule(1); // For MSP430FR5994 SCL(1) = pin 5.1   //  SCA(1) = pin 5.0
  Wire.begin();
  Serial.begin(9600);
  Serial.println("\nlm75 Sensor");
}

void loop() {
  // put your main code here, to run repeatedly:
   byte t;
    Wire.requestFrom(0x48, 1);    // request 6 bytes from slave device #2
    if(Wire.available()) t= Wire.read();   // if(Wire.available()) t[1]= Wire.read();
    Serial.print("temp: ");
    Serial.print(t);
    Serial.print("\n");
    delay(1000);
}

lm75-sensor.ino

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...