Jump to content
43oh

Help to optimize


Recommended Posts

The error in the code is mentioned here:

http://www.rcgroups.com/forums/showthread.php?t=1197534

 

This is the code the I finally settled on in my own test project:

  //calculate the temperature
 x1 = (ut - ac6) * ac5 >> 15;
 x2 = ((int32_t) mc << 11) / (x1 + md);
 b5 = x1 + x2;
 *t = (b5 + 8) >> 4;

 //calculate the pressure
 b6 = b5 - 4000;
 x1 = (b2 * (b6 * b6 >> 12)) >> 11;
 x2 = ac2 * b6 >> 11;
 x3 = x1 + x2;
 b3 = (((int32_t) ac1 * 4 + x3) << BMP085_OSS) >> 2;
 x1 = ac3 * b6 >> 13;
 x2 = (b1 * (b6 * b6 >> 12)) >> 16;
 x3 = ((x1 + x2) + 2) >> 2;
 b4 = (ac4 * (uint32_t) (x3 + 32768)) >> 15;
 b7 = ((uint32_t) up - b3) * (50000 >> BMP085_OSS);
 *p = b7 < 0x80000000 ? (b7 * 2) / b4 : (b7 / b4) * 2;

 x1 = (*p >> 8) * (*p >> 8);
 x1 = (x1 * 3038) >> 16;
 x2 = (-7357 * *p) >> 16;
 *p = *p + ((x1 + x2 + 3791) >> 4);

Link to post
Share on other sites
  • 10 months later...
I'm building a small project with a msp430G2231 and a pressure sensor (bmp085) connected through i2c. I'm also using a snippet of code to output code through serial port.

My problem is that the code compiled exceeds the flash size of the uc, but I'm sure there are things that can be optimized. So I'm asking to more expert people about how to optimize it.

Thanks in advance

When I try to run the code, it says a lot of stuff is undefined...

 

EDIT: Never mind I was just using a different compiler...

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