Anyone used the Bosch BMP085 I2C baro sensor yet ?


Closed Thread
Results 1 to 40 of 52

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default Bigger PIC's....

    Hmm...
    I've written all the 32Bit calculation code now using PBPL and Longs, where they are needed (well nearly everywhere).
    Right away I got a list of very strange compiler errors like this
    c:/pbp/pbppi18l.lib 695 : Argument out of range ( 4168 not between 0 and 4095)

    After having a look at line 695 of that file I still had no clue. So I took a punt that I might have run out of PIC code space, and yes that seems to be right. If I select a PIC in the same sub family with more code space the code complies error free....
    Longs sure burn code space like it was endless resource.
    Off to find a another bigger PIC again. This will be the 4th PIC tried for this project.


    Onward and upwards !!

    PS. Is there a simple to use utility, MCS add-on or method that will show me the amount of RAM space my code is using when compiled (as well as program space) ?
    Last edited by mr.sneezy; - 28th May 2010 at 14:02.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Quote Originally Posted by mr.sneezy View Post
    Hmm...
    I've written all the 32Bit calculation code now using PBPL and Longs, where they are needed (well nearly everywhere).
    Right away I got a list of very strange compiler errors like this
    c:/pbp/pbppi18l.lib 695 : Argument out of range ( 4168 not between 0 and 4095)

    After having a look at line 695 of that file I still had no clue. So I took a punt that I might have run out of PIC code space, and yes that seems to be right. If I select a PIC in the same sub family with more code space the code complies error free....
    Longs sure burn code space like it was endless resource.
    Off to find a another bigger PIC again. This will be the 4th PIC tried for this project.


    Onward and upwards !!
    Hi,

    Looks linked to too small a program memory ... in 18 pins ... the 1320 exists in 8k ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Hi Alain,

    Yes, it compiles OK if I select that one, at about 5200 bytes.

    As I have to buy the next size PIC I might as well jump to the 18F2520 with huge code space and 28pins, although I really am only using a few I/O at the moment. Going to be lots of unused I/O's.

    Martin

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mr.sneezy View Post

    PS. Is there a simple to use utility, MCS add-on or method that will show me the amount of RAM space my code is using when compiled (as well as program space) ?
    Nice work on the sensor code!

    MCS shows you how much code is being used at the bottom of the page after compliling. (Note it does need a successful compile to be able to tell you this.)

    Name:  size.png
Views: 4302
Size:  17.1 KB

    You can also peek in the .lst file, and find code used vs left.

    Code:
    MEMORY USAGE MAP ('X' = Used,  '-' = Unused)
    
    
    0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0140 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0180 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXX-------
    0200 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0240 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    0280 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
    02C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX ---------------- ----------------
    2000 : -------X-------- ---------------- ---------------- ----------------
    
    All other memory blocks unused.
    
    Program Memory Words Used:   665
    Program Memory Words Free:   359
    Then there is also Darrel's CodeSpace utility here:
    http://www.picbasic.co.uk/forum/showthread.php?t=2418
    Last edited by ScaleRobotics; - 28th May 2010 at 15:21.

  5. #5
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Nice work on the sensor code!
    Thanks, although it's not complete just yet. I'll show you the main sensor code snip in case you are interested. It complies now (if selecting a bigger PIC) and I know the result of the lCTemp section is 100% correct (+ & - Deg C ). The UPres calculations are as of right now untested.
    If you see any blindingly obvious code bloat in the calculations let me know...
    I will post the complete code as soon as I know it works fine.

    I did know what the code size used was telling me in MCS, I was more curious about RAM (variables etc) as I have been caught before going to a PIC with more code space, only to be quickly stumped by running out of variables...

    All variables are signed Longs, except MD, AC5 and AC6 which are Words.
    Code:
    'Calculate temperature in 1/10ths of Deg C  from lUTemp     ' Note 2^15 = 32768 Dec or $8000
            X1 = ((lUtemp - AC6) * AC5) / $8000     'find X1 
            X2 = (lMC << 11) / (X1 + MD)            'Find X2
            B5 =  X1 + X2                           'Find B5 from X1 and X2
            lCTemp = (B5 + 8) / 16                  'Hey presto, lCTemp appears... 
              
    'Calculate pressure in Pa from lUpres (1/100th's of hPa's)        
            B6 = b5 - 4000
            x1 = (b2 * (B6 * B6 / $1000)) / $800 
            x2 = (lac2 * B6) / $800
            x3 = x1 + x2
            B3 = ((lac1 * 4 + x3) << 5) / 4         'My OSS = 3 (might need to * here not <<)
            x1 = (lac3 * b6) / $2000
            x2 = (b1 * (b6 * b6 / $1000)) / $10000
            x3 = ((x1 + x2) + 2) / 4
            B4 = (lac4 * (x3 + 32768)) / $8000
            B7 = (lUPres - B3) * 50000
            If B7 < $80000000 then 
                lPres = (B7 * 2) / B4
            Else
                lPres = (B7 / B4) * 2
            Endif
            X1 = (lPres / 256) * (lPres / 256)
            X1 = (X1 * 3038) / $10000
            X2 = (-7357 * lPres) / $10000
            lPres = lPres + ((X1 + X2 + 3791) / 16)
    
            Serout2 SO,16780,["T=",DEC lCtemp,"    "]       'Send Word size number to LCD
            Serout2 SO,16780,["P=",DEC lPres,"     "]      'Send Word size number to LCD

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts