Re: FPU problem urgent

Khairul Nizam <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
thanks julian for your advice..
 
i have already enable the hardware floating point support...
 
how to modify the FPSCR content?....do you have simple C code to do it?....because i have tried to find the FPSCR address...but still didnt found any.
 
Using FPU seems not so easy as I thought.thanks...

Julian Requejo <[email protected]> wrote:
Hi Khairul,

I am not entirely sure what the problem but I have two
ideas in minds:
A silly one: have you enabled floating-point support
at all? I don't use CW, but I guess you probably have to
enable this manually.
Second: could this be IEEE floating point exeptions
due to rounding errors? Have you checked the cause of
the exeption? You can put an exeption handler and look
at the status flags. In any case, when I use floating
point, I usually disable the IEEE mode since I don't
need these capabilities. Unless your application is
safety critical, I would disable this. Otherwise,
things like a converging algorithm will trigger an
exeption once the value converges to zero and becomes
exactly zero due to round-off errors. Try disabling
this. Add

mtfsb1  29       # FPSCR:NI(29): enter Non-IEEE mode

to your startup function.

Now some general sugestions: avoid mixing floating
point a fix point, unless you have a reason for that
(i.e. a variable is used by both floating and fix
point routines/libraries. Converting between integer
and floating takes time and makes the code more
error-prone. I wouldn't do it unless you need the
fixed point version of the variable or do a lot of fix
point math with them later. The line "if
(ordinate>(float)0)", change it to "if
(ordinate>0.0)". In this way, the zero value as a
float is compiled statically, rather than converted
from an integer to float during run-time.
I hope this helps somehow...
Cheers,
-Julian


On 5/20/05, Khairul Nizam <[email protected]> wrote:
> hi there
> 
> I am very new with MPC555 and now I am trying to use
the FPU to perform some simple arithmaatic
operation....,now I am having problem with it,I have
stuck with it for 1 week......please help me...
> 
>  the problem is...
> 1.the debugger hang/cannot step over to the next
instruction,it stop at the last floating point
operation.
> 2.if I remove the other floating point
operation,meaning that only 1 floating point operation
done,the debugger runs ok.
> 3.If i check the mixed assembler and source created
by CW...they show me this(the insructions below)...it
seems to me that the invalid opcode have been included
by the compiler....
> 
> 
> please,hope someone can help me with this,because I
am planning to use FPU for bigger task.I am using
CW6.6 and Abaltron BDI2000 debugger.Thanks
> 
>  ordinate=(AtoD*table_x)/(float)max_AtoD; //even
spacing between adc value:need further study
> 003FA004: 00000000  dc.l     0x00000000             
; Invalid opcode '....'
> 003FA008: 3C800040  lis      r4,64
> 003FA00C: DBE10028  stfd     fp31,40(SP)
> 003FA010: 38A4A2A0  subi     r5,r4,23904
> 003FA014: C8650000  lfd      fp3,0(r5)
> 003FA018: 93E10024  stw      r31,36(SP)
> 003FA01C: 3BE00000  li       r31,0
> 003FA020: 93C10020  stw      r30,32(SP)
> 003FA024: 3BC00068  li       r30,104
> 003FA028: 93A1001C  stw      r29,28(SP)
> 003FA02C: 3BA0000A  li       r29,10
> 003FA030: 7C1EE9D6  mullw    r0,r30,r29
> 003FA034: 93810018  stw      r28,24(SP)
> 003FA038: 90610008  stw      r3,8(SP)
> 003FA03C: 9001000C  stw      r0,12(SP)
> 003FA040: 3B800400  li       r28,1024
> 
> ///////////////////////////////////////////////the
real code////////////////////////////////////////
>  void main()
> {
> 
>  float ordinate;
>  unsigned int AtoD,i=0;
>  unsigned int table_x;
>  unsigned int max_AtoD;
>  //unsigned int ordinate_less;
> 
> 
>  AtoD=104;
>  table_x=10;
>  max_AtoD=1024;
> 
> 
>  ordinate=(AtoD*table_x)/(float)max_AtoD;
> 
> if (ordinate>(float)0)
> i=1;
> else
> i=0;
> 
>  while (1) { i++; }   // loop forever
> }
> 
> 
> 
> 
> 
> ---------------------------------
> Yahoo! Mail
>  Stay connected, organized, and protected. Take the
tour
> 
> [Non-text portions of this message have been
removed]
> 
> 
> 
>
-----------------------------------------------------------
> To learn more about Freescale Microcontrollers,
please visit
> http://www.freescale.com/mcu
> 
> 
> 
> Yahoo! Groups Links
> 
> 
>    [email protected]
> 
> 
> 
> 


-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu






---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/MPC500/
  
   To unsubscribe from this group, send an email to:
[email protected]
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


		
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 

[Non-text portions of this message have been removed]



-----------------------------------------------------------
To learn more about Freescale Microcontrollers, please visit
http://www.freescale.com/mcu


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/MPC500/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.