Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

math functions and mplab + c18

Status
Not open for further replies.

eng.alamin

New Member
hello

when i added this function into my c18 code i had hung in execution
am using pic18f4550

some buddy's said to me that i may facing stack over flaw case although there is no warnings or error message during compiling
but i increased stack first to 512 but nothing change so i jump to 1024 stack i removed all usb stack .
all that and nothing change these is function which cause hung in process
---------------
Code:
  float dstance(  float lat1,  float lon1,  float lat2,  float lon2)
        {
       

   static float a,c , y ;
float d;

           lon1 *= 3.14159265 / 180;
            lat1 *= 3.14159265 / 180;
            lon2 *= 3.14159265 / 180;
            lat2 *= 3.14159265 / 180;

    a = sin(  (lat2 - lat1)/2) ; 
     a *= sin((lat2 - lat1)/2) ;
     y =  cos(lat1) * cos(lat2) ;
     y *= sin((lon2 - lon1)/2) ;
    y *= sin((lon2 - lon1)/2);
     
     y += a ;
     c = 2 ;
  a = sqrt(1-(y ));
  y = sqrt(y) ;
  c *= atan2( y , a );
   
      d = 6371 * c;
  
    
            return 6371 * c;
        }


but when i remove c *= atan2( y , a ); program run good in MCU

help !! please :confused:
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top