Unable to link , please help .

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to link , please help .

5,928 Views
sudip
Contributor I
Hii everybody,
 
 
This is my first post in this forum .
 
I am  new to motorola controllers  and  code warrior IDE using C. I am using a math function asin() from the standered C library.
 
when ever I compile my code , I get  a link error . can any body there to say how to overcome.
 
I am sorry for my silly problem.     Thanks  in advance.
 
following is the simplified programme which demonstrates  my problem.
 
 
  #include <hidef.h>    /* for EnableInterrupts macro */
   #include <MC68HC908QY4.h>    /* include peripheral declarations */
   #include <math.h>
   
   
  float  asinf (float x); 
    
  float x,y;
   
   void main(void)
   {
     
     y= asinf(x);
     
   }
 

    
 
Errors & warnings
 
Link Error   : L1822: Symbol asinf in file E:\mot_test\test3\math1\math1_Data\P&E_FCS\ObjectCode\main.c.o is undefined

Link Error   : Link failed
 
Labels (1)
0 Kudos
7 Replies

503 Views
peg
Senior Contributor IV

Hi sudip,

When you start the project you need o include floating point support, although this device seems not to have enough memory to support this.

BR Peg

 

0 Kudos

503 Views
rhinoceroshead
Contributor I

With only 4k of ROM, I might suggest not using floats and not using the math library.  Most likely you're not using the full capabilities of the code you're trying to include anyway.  Find out what range of numbers you really need to respresent and how much accuracy you need and then represent it with a struct using chars and ints.  For functions like arcsin, you can do linear approximations or use a lookup table.  If your application really needs to use a float and asinf then you should find a part with more ROM.

What's the application?

By the way, the code you posted here compiles to 4494 bytes so you're barely over the limit.  If your program is not too long, you might get away with using a QY8 instead of a QY4.

Message Edited by rhinoceroshead on 04-29-200612:31 PM

0 Kudos

503 Views
sudip
Contributor I
Thanks to peg and rhinoceroshead.
 
Actually I need to calculate the tilt angle of an object  from the horizontal plane in both X and Y axis( I am using ADXL213 -dual axis accelerometer).
 
To calculate the tilt angle  (    PITCH=ASIN(Ax) and ROLL=ASIN(Ay)  )   from the output signal I have to use the ASIN function.
 

PITCH=

 ASIN (AX  )          

ROLL

= ASIN (A )
 
where Ax and Ay both varies between -1 to +1 . I reqire a accuracy of about  +/-  2 degree.
 
Pitch and roll are the tilt in X and y axis from the horizontal plane.
 
I agree with rhinoceroshead I do not  require very high accuracy , so doing with a look up table may be good Idea.
 
 
 
"Find out what range of numbers you really need to respresent and how much accuracy you need and then represent it with a struct using chars and ints"
 
 
 
anybody there to   explain this in some more detail with an example ?
 
 
Best  regards ,
 
                                                                                        Sudip
 
 
 
0 Kudos

503 Views
peg
Senior Contributor IV

Hi Sudip,

just make a 90 entry (16-bit) table of all your raw timer values that equate to 0 to 90 degrees.

Then when you have got your value walk through the table looking for the first one over (or under). If you jump in the middle first thats a maximum of 45 compares to do the conversion.

BR Peg

 

0 Kudos

503 Views
sudip
Contributor I
Thanks peg .
 
 
                                         Sudip
0 Kudos

503 Views
rhinoceroshead
Contributor I
Yep, you don't need to use floats since your input capture will give you an integer.  You also may be able to speed up your asin function by walking a binary tree instead of a table, but that would take about twice as much ROM as the table.
 
When I was talking about representing a number using a struct, I was trying to say that you could make a 'minifloat' structure where you could, for example, use one char to represent the number -128 through 127 and then another char could represent the exponent.  You would then implement a minifloat_add(minifloat x, minifloat y) function and any other math routines that you need.  This is all the compiler is doing for you anyway when you use floats since the CPU can't do floating point arithmetic, except it is using more precision than you care about.  You can also do scaling to avoid using floats.  If the number you want to repesent is always between -99.99 and 99.99 then notice that you can multiply the entire range by 100 and then everything fits nicely in an int, which holds -32768 through 32767.  Now you can do all your math with ints and when it comes down to displaying the number to the user, you can do integer division by 100 to show the -99 through 99 part and then use modulus 100 to get the fraction.
0 Kudos

503 Views
sudip
Contributor I
Thanks for your valuable suggestion.
 
                                                                                   Sudip
 
                     
0 Kudos