Jump to content
43oh

MSP430FR6969 Launchpad + HDC2010 (I2C temp sensor) problem


Recommended Posts

I'm trying to connect the HDC2010 temperature sensor to the MSP430FR5969 Launchpad.

I'm using the HDC2010 EVM, which consists of a MSP430F5528 (which handles USB communications to the GUI tool) and a HDC2010 (connected over I2C). The portion with the HDC2010 can be broken off from the main board in order to use it with another MCU.

I'm attempting to connect it to a MSP430FR5969 Launchpad which has the SHARP Memory LCD (uses SPI) connected to it. I couldn't find a ready made library for the HDC2010 & MSP430, so I copied over some code from the Arduino library.

To check whether I was using the HDC2010 correctly, I first used the following code (mostly taken from the HDC2010 lib) and used an Arduino Uno. I used MOSFET level translators (since the Arduino is 5V, HDC2010 is 3.3). I did not break off the HDC2010 section from the main board of the EVM, so the main MSP430F5528 was still connected to the HDC2010, but I guess it was idle.

#define ADDR 0x40
#include <Wire.h>

//Define Register Map
  #define TEMP_LOW 0x00
  #define TEMP_HIGH 0x01
  #define HUMID_LOW 0x02
  #define HUMID_HIGH 0x03
  #define INTERRUPT_DRDY 0x04
  #define TEMP_MAX 0x05
  #define HUMID_MAX 0x06
  #define INTERRUPT_CONFIG 0x07
  #define TEMP_OFFSET_ADJUST 0x08
  #define HUM_OFFSET_ADJUST 0x09
  #define TEMP_THR_L 0x0A
  #define TEMP_THR_H 0x0B
  #define HUMID_THR_L 0x0C
  #define HUMID_THR_H 0x0D
  #define CONFIG 0x0E
  #define MEASUREMENT_CONFIG 0x0F
  #define MID_L 0xFC
  #define MID_H 0xFD
  #define DEVICE_ID_L 0xFE
  #define DEVICE_ID_H 0xFF

float temperature = 0, humidity = 0;
void openReg(uint8_t reg)
{
  Wire.beginTransmission(ADDR);     // Connect to HDC2010
  Wire.write(reg);            // point to specified register
  Wire.endTransmission();         // Relinquish bus control
}

uint8_t readReg(uint8_t reg)
{
  openReg(reg);
  uint8_t reading;          // holds byte of read data
  Wire.requestFrom(ADDR, 1);     // Request 1 byte from open register
  Wire.endTransmission();       // Relinquish bus control
  
  if (1 <= Wire.available())
  {
    reading = (Wire.read());      // Read byte
  }
  
  return reading;
}
float readTemp(void)
{
  uint8_t byte[2];
  uint16_t temp;
  byte[0] = readReg(TEMP_LOW);
  byte[1] = readReg(TEMP_HIGH);
  
  temp = (unsigned int)byte[1] << 8 | byte[0];
  
  return (float)(temp) * 165 / 65536 - 40;
}
void writeReg(uint8_t reg, uint8_t data)
{
  
  Wire.beginTransmission(ADDR);    // Open Device
  Wire.write(reg);            // Point to register
  Wire.write(data);           // Write data to register 
  Wire.endTransmission();       // Relinquish bus control
  
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(temperature = readTemp());
  //Serial.println(humidity = readHumidity());
  delay(1000);
}

This code worked and I got temperature readings.

Next, I tried it out on the MSP430FR5969, again, without breaking off the sensor from the mainboard. It didn't work at first, so I checked with a logic analyzer and if I recall correctly, either the SCK or SDA lines wasn't sending any data. However, after sometime it started working properly, and then stopped again.

After trying for a couple of hours, I decided to disconnect the HDC2010 from the mainboard, in case the MSP430F5528 was causing some issues. I connected the HDC2010 to the Arduino Uno via the logic level shifter, and the code worked correctly. However, it doesn't work with the MSP430FR5969. I tried out the inbuilt Wire examples, and the logic analyzer reveals that the I2C lines don't seem to be sending data at all (they work fine as GPIO). 

I'm using pins 9 & 10 on a Rev2.0 launchpad. What's odd is that it worked for a little while & I cannot figure out what I'm doing wrong.

 

This is with a 1.2k ohm pull up on the clock line (2nd row). Without the pull up, the line remains low. The first row shows SDA, but the logic is inverted for some reason, and if I use a 10k pull up, it remains high continuously.

image.thumb.png.0a7636ab71ddc6b1a4f8e6ecdf0893ea.png

I managed to capture this when it worked correctly with the MSP430FR5969:

image.thumb.png.bc3d00ffbc0358dcbde5fa1416b71486.png

 

I've read conflicting reports about the actual I2C pins on the MSP430FR5969 launchpad: are they at 9 & 10 (as the board pdf & silkscreen says), or have they been shifted to the same pins as SPI?

What's the best way to debug this? Simple I2C sketches don't seem to work for some reason, but it worked correctly for a little while.

Link to post
Share on other sites

I'm using the SCL(1) & SDA(1), which are the default.

I tested it out with a 16x2 LCD which has a I2C to parallel converter.

This is what it looks like when connected to the I2C converter; the SCK line goes low, but SDA remains high.

image.thumb.png.9845179e258108325c1deaf67276ecce.png

If I leave SDA floating, I get this:

image.thumb.png.f3325478618cbdd7123785a854bc0c63.png

Notice that the SDA line remains low, but actually goes high during data transmission for some reason: how is this happening, since I2C is supposed to be open drain?!?

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