HC12: Codewarrior do not execute the Function

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

HC12: Codewarrior do not execute the Function

3,934 Views
JR
Contributor I
Hi friends !
 
I am trying to make the function below. It is not functioning. The compiler Codewarrior 3,1 accuses error and appears the following message :
Link error ; L1822:smileyfrustrated:ymbol _FUFLOAT in file c:\....main.c.o is undefined.
Link error ; L1822:smileyfrustrated:ymbol _FDIV_RC in file c:\....main.c.o is undefined.
Link error ; L1822:smileyfrustrated:ymbol _MUL in file c:\....main.c.o is undefined.
Link error ; L1822:smileyfrustrated:ymbol _FSTRUNC in file c:\....main.c.o is undefined.
 
This are the codes:
 
  while (1)  // always
 {
 unsigned int res1,res2,res3;
  res1=10;
  res2=100;
  res3=prod(&res1,&res2);// Here i call the function
}
 
 
unsigned int prod (unsigned int *a,unsigned int *b) // This is the Function
{
unsigned int tempa;
unsigned int tempb;
unsigned int tempc;
signed int t;
float x;
tempa=*a; //tempa is a number between 1 to 100
tempb=*b; //tempb is a number between 1 to 100
x=(tempa/100.0)*tempb;
t=(signed int)x;
tempc=(unsigned int)t;
return(tempc);
}
 
what's wrong? Already it makes many days that I am trying and i don't know what to do to function.  Please,  help me! Thanks , JR

Message Edited by CrasyCat on 2007-04-13 02:30 PM

Labels (1)
Tags (1)
0 Kudos
Reply
6 Replies

496 Views
bigmac
Specialist III
Hello JR,
 
Yes, the use of the float is the current problem.  However, since you commence with int data, and return an int, it should be possible to avoid using float within your function.  This will greatly improve the efficiency of your code.
 
The following calculation should maintain unsigned int precision, with a calculated value between 0 and 100.
 
tempc = tempa * tempb / 100;

Alternatively, i would think you could simply write the contents of the function as -
 
unsigned int prod (unsigned int *a,unsigned int *b)
{
  return ((*a) * (*b) / 100);
}
 
Regards,
Mac
 
0 Kudos
Reply

496 Views
JR
Contributor I
Hi friend !
Your explanation helped to solve  the problem, thank you !
0 Kudos
Reply

496 Views
admin
Specialist II
Hello:
 
It seemed float type is used in you project, but you did not select "float type support" when you create your project.
 
Just re-create a new project and select "float support", and rebuild it.
0 Kudos
Reply

496 Views
JR
Contributor I
Hi Markie !
 
You are right ! Thank you ! JR
0 Kudos
Reply

496 Views
Lundin
Senior Contributor IV
No need to create a new project.

Assuming you are using HCS12 with banked memory model:

- Take a backup copy of your project (just in case...)
- Remove ansibi.lib from your project.
- Add ansibf.lib to your project.
0 Kudos
Reply

496 Views
pilou007
Contributor I

Hy,

Sorry to re-open this topic, I'm a total newbie in µC, and I got this error too, how can I do what you say??

best regards

Pilou007

0 Kudos
Reply