This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430g2553 Natural log calculation problem

Other Parts Discussed in Thread: MSP430G2553, MSPMATHLIB

Hello, This is Pratik Debnath is using Msp430g2553,

I have some issue with floating point..

I am dividing two floating point number-

after that I am calculating the Natural log

after that I am finding that any multiply,division or adding float or int is giving erroneous  result in my msp430g2553 emulator.


#include "msp430g2553.h"
#include<math.h>
#ifndef TIMER0_A1_VECTOR
#define TIMER0_A1_VECTOR TIMERA1_VECTOR
#define TIMER0_A0_VECTOR TIMERA0_VECTOR
#endif

float v1=0,v2=0,v3=0,Vr1=0,k;
float l;
unsigned int j=1,i=2;

float find_bodyresitance(unsigned int);
//float findnext_cycletimecount(float body_resistance);

main()
{

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |=BIT5;
P1OUT&=~(BIT5);
      while(1)
   {

v1=1630;
v2=1186;
v3=395;
Vr1=v1/v2;
 k=(float) log((double) Vr1);     // Natural log gives right result but after this whatever I try to calculate multiply float,int gives wrong result 
l=(6*i)/k;
 if(l>13.0 && l<14.0)
{
P1OUT|=(BIT5);
_delay_cycles(125000);
_delay_cycles(125000);
P1OUT&=~(BIT5);
_delay_cycles(125000);
_delay_cycles(125000);
}

}
}

PLEAE HELP  ME...AND SUGGEST ME THE FLOATING POINT AND NATURAL LOG CALCULATION..

ALSO TELL ME IF MSPMATHLIB IS SUPPORTED in Msp430g2553



  • Hello, Pratik!

    The operations you're doing are power intensive. To minimise the burden on MSP, you've to make use of "Hardware Multiplier". Please go ahead and have a look at examples at Resource Explorer -> MSPWare -> Libraries ->  IQMath Library -> MPY Software. 

    I encourage you to read User's Guide before you proceed. Choosing a right _q value is very crucial for your system to run without any bugs.

    Should you've any queries, feel free to ping me.

**Attention** This is a public forum