chicken

[Energia Library] Bosch BMP085 Template Library

58 posts in this topic

@@RobLewis @@bogdanvisan20
 
Ok, I rewrote the I2C part of the library so that it properly uses beginTransmission and endTransmission() and it now seems to work with Energia 16 and the G2 launchpad.

 

I remember that I had to fudge with begin/endTransmission originally to work around oddities of the Energia I2C implementation. It looks like Energia is fixed now and my workarounds are broken.

 

Below the corrected bit of code (towards the bottom of BMP085_t.h). I will update it on GitHub shortly.

  // send command to BMP085
  void m_sendCmd(uint8_t cmd) {  
    Wire.beginTransmission(i2caddress);
    Wire.write(byte(BMP085_REG_CTRL));      
    Wire.write(byte(cmd));
    Wire.endTransmission();
  }
  
  // read 8 bits from I2C
  uint8_t m_read8(uint8_t addr) {
    uint8_t ret;

    Wire.beginTransmission(i2caddress);
    Wire.write(addr);
    Wire.endTransmission();

    Wire.beginTransmission(i2caddress);
    Wire.requestFrom(i2caddress, (uint8_t)1);    // need to cast int to avoid compiler warnings
    ret = Wire.read();
    Wire.endTransmission();
	
    return ret;
  };

  // read 16 bits from I2C
  uint16_t m_read16(uint8_t addr) {
    uint16_t ret;
	
    Wire.beginTransmission(i2caddress);
    Wire.write(addr);
    Wire.endTransmission();

    Wire.beginTransmission(i2caddress);
    Wire.requestFrom(i2caddress, (uint8_t)2);    // need to cast int to avoid compiler warnings
    ret = (Wire.read() << 8) | Wire.read();
    Wire.endTransmission();
	
    return ret;
  };
Fmilburn likes this

Share this post


Link to post
Share on other sites

Very cool, thanks @@chicken

 

Do you have any idea whether this may restore the routine's ability to work at a 16MHz clock rate in the F5529? (I found that in later versions of Energia even the patched code would only work at 25 MHz). 

Share this post


Link to post
Share on other sites

hello ...i am very new to this world...i have to interface bosch bme280 with msp432 launchpad...i have done 12c interface and have been able to see the output in serial monitor of energia ...i have a sharp lcd boosterpack and have to show the sensor output there but dont know how ..can anyone help ??

Share this post


Link to post
Share on other sites

1 Thanks for this library, very useful

2 I have been struggling for a long time to get this to work. I tried energia v17 and it wouldn't work but the cause wasn't obvious to me.  So i tried many things and wories I'd fried something.  Changing to energia v16 it worked immediately

 

I have an msp430g2553 with msp-exp430g2 rev1.3.  I have also removed c24 and r34 (I can't remember why) and have txd and rxd cross jumpered.  I am running a BMP85 chip that I've soldered myself with 5k pullups and decoupling cap.

 

Hope this helps someone

Share this post


Link to post
Share on other sites

I haven't tried Energia 17 myself yet. I've read somewhere that I2C was moved to different pins, but not sure if that also applies to the G2553 LP.

Share this post


Link to post
Share on other sites

in my NSpace demos renders and fills polygons too, even in different states of flipping and rotation. Not sure how that library compares but it would be interesting to find out.

Share this post


Link to post
Share on other sites
On 12/19/2015 at 2:58 PM, Towhid said:

hello ...i am very new to this world...i have to interface bosch bme280 with msp432 launchpad...i have done 12c interface and have been able to see the output in serial monitor of energia ...i have a sharp lcd boosterpack and have to show the sensor output there but dont know how ..can anyone help ??

Could you share the code for this?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now