Hello
I have problem with my program. If I would like compile my program, Linker show error.
Symbol _FSFLOAT
Symbol _FMUL
Symbol _FSTRUC
Symbol _FDIV
.
.
.
/*MEM hlavickovy soubor*/
#ifndef _MEM_
#define _MEM_
#define F_OSC 16
#define F_BUS 8
#define T_BUS .125
int Initi(int);
#endif
/*mem.c */
#include "eeprommm.h"
#include <mc9s12dp256.h>
#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
int Initi(int oscclk){
unsigned char prdclk;
float eeclk = 0;
int pom = 0;
ECLKDIV_PRDIV8 = 0;
if(oscclk >=12){ /*MHz*/
ECLKDIV_PRDIV8 = 1;
prdclk = (unsigned char)(oscclk/8);
}else{
prdclk = (unsigned char)(oscclk*(5+.125));
}
pom = (int)(oscclk*(5+.125));
ECLKDIV_EDIV = (unsigned char)pom;
eeclk = 2/(1+pom);
if((((1/eeclk)+T_BUS) >= 5) && (eeclk > .15)){
return 0; /*ok*/
} else{
return 1; /*bad*/
}
}
Solved! Go to Solution.
Try searching the forum, for example
http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=2244
Basically the project links against the integer only ANSI library therefore the floating point runtime support routines are not available.
Alternatively you might change the source code not to use floating point calculations. For example instead of
> prdclk = (unsigned char)(oscclk*(5+.125));
You get the same result with
prdclk = (unsigned char)(((oscclk*5125uL)/1000));
or
prdclk = (unsigned char)(((oscclk*41uL)/8)); // * (5+.125)
I used long, maybe int arithmetic is enough.
Either way, both long and int arithmetic are a lot faster and shorter than using floating point.
Daniel
Try searching the forum, for example
http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=2244
Basically the project links against the integer only ANSI library therefore the floating point runtime support routines are not available.
Alternatively you might change the source code not to use floating point calculations. For example instead of
> prdclk = (unsigned char)(oscclk*(5+.125));
You get the same result with
prdclk = (unsigned char)(((oscclk*5125uL)/1000));
or
prdclk = (unsigned char)(((oscclk*41uL)/8)); // * (5+.125)
I used long, maybe int arithmetic is enough.
Either way, both long and int arithmetic are a lot faster and shorter than using floating point.
Daniel
Great. It works thank you very much.