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