I2C for beginners (Using BMP085 Barometer)
Shawna
Posts: 508
Hey guys,
My Spin skills and PASM skills are not real great, I am learning more and more everyday but I am still a beginner. I want to play with a BMP085 barometer and I am trying to locate an I2C driver to use. I have been looking at the Basic I2C Driver but in the description it states that the code assumes there are no pull-up resistors on SDA and SCL. I have the BMP085 breakout board from sparkfun and the schematic shows there being pull-up resistors on the board.
My question is, can I still use this code with the BMP085, or any I2C device that already has pull up resistors built in?
Thanks
Shawn
My Spin skills and PASM skills are not real great, I am learning more and more everyday but I am still a beginner. I want to play with a BMP085 barometer and I am trying to locate an I2C driver to use. I have been looking at the Basic I2C Driver but in the description it states that the code assumes there are no pull-up resistors on SDA and SCL. I have the BMP085 breakout board from sparkfun and the schematic shows there being pull-up resistors on the board.
My question is, can I still use this code with the BMP085, or any I2C device that already has pull up resistors built in?
Thanks
Shawn
Comments
Most slave devices don't do it, but Micro-controller based modules may very well do it.
Since the answer is yes, thank you SRLM. Do I need to modify the Basic I2C Driver code? My guess is no!
This is the simple program I wrote to read out the calibration E2PROM on the BMP085, The BMP085 manual says communication can be checked by reading these registers. 0 and FFFF are invalid numbers from these registers and I got 0 for all of them. I would say this means I did not communicate at all with the chip. I am sure I missed something simple, this should not be complicated. Here is my code if anyone would like to take a look.
Thanks
Shawn
If I change the address to $77 then I get a -1 back. What does the -1 signify? The code says that if a error occurs it will return true. -1 surely is not true is it? This is one thing I need to learn in order to read and write code better. So I am assuming that I have the right address since I do not get a -1 when I use the address %1110 1110. Or could the address still be wrong?
The example that I was basing my code off of read the BMP085 registers as a word. I saw the addresses in the data sheet as byte size but I think I can read a whole word out, I don't think that is the problem. I tried modifying the code to read just one byte out and it still read out 0's.
I might have found the problem, in order to read the device I think I have to use %1110 1111 and to write I have to use %1110 1110. I am going to try that now.
Thanks
Shawn
It did not show up properly in my post above.
Also I am using V1.3 Basic I2C Driver.
Shawn
I tried %1110 1110 and %1110 1111.
Thanks
Shawn
Thanks Again
Shawn
On to the next section of code for the BMP085. I need to send a request for a temperature reading. The register address is $F4 and the control register value should be $2E if I read the manual right. After sending the request for a temperature reading I have to wait for 4.5mS before I can try to read it. Now that I have waited 4.5mS I should be able to read the temperature out of register $F6 MSB and register $F7 LSB. When I add the code below to my main program I get a value of 128 all the time for my Temperature1 variable, it never changes. I do not think my request for a temperature reading is making it to the BMP085. The reason I don't think it is making it, is because the BMP085 has a END OF CONVERSION line that should change from a logic 0 to a logic 1 when the temperature reading is ready to be read. The EOC is never changing state to a logic 1, I hooked my scope to it.
I tried a bunch of different things with no success.
Thanks
Shawn
I tried placing the I2C#OneAddr in the writebyte command initially but I put it in the wrong spot. When I do this I2C.WriteByte(8, $EE, $f4| I2C#OneAddr, $2e) my END OF CONVERSION pin changes to a logic 1 and I am able to read a value out of the device for temperature. I haven't figured out what the variable means yet, it seems strange that a bunch of math is required just to get the temperature.
Shawn
Now it is time to read out the Pressure! I am having a hard time understanding the data sheet. The Uncompensated Pressure can be read out in either a 16 bit or 19 bit value. This is what I have tried, does this look reasonable, or does it look messed up. I am about ready to write the Compensated Pressure routine. When I run this program I do get a reading. The reason I question this is, if I read out MSB, LSB, and XLSB and display them individually I get strange values. MSB should be 8 bits, LSB should be 8 bits, and XLSB should be 3 bits. However my XLSB value can be as high as 128, and I don't understand how you can get 128 from a 3 bit value.
Also I do not understand this equation either but it came straight out of the data sheet.
UP := (MSB<<16 + LSB<<8 + XLSB)>> (8 - Mode)
Thanks
Shawn
Thanks
Shawn
Thanks again Kuroneko and also to Tim Moore who's program I modeled mine off of. I think I have a better understanding of the Basic I2C Drivers now also. I will post my code once I have it cleaned up.
Shawn