Re: FPU problem urgent

Khairul Nizam <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
thanks julian
 
your reply really helps me to understand the FPU abit.
I will try what you have suggested right away.
 
another thing,do you have any note/manual to use the fpu in the mpc555?I think i have to know the detail about it.since i dont know the correct flow on setting up and using the FPU correctly....or you might suggest me some basic steps to start with in order for me to perform floating point culcuation....
 
best regards
 
nizam

Julian Requejo <[email protected]> wrote:
For the non-IEEE mode, all you have to do is issue the assembly command that
I've writte in my last email:

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

Usually you put this assembly line in your startup.s, begin.s, crt0.s, etc.
This depends on your compiler, operating system, or how you initialize your
stuff. I usually put it somewhere where I initialize my system (i.e. memory
controller initialization, etc). If you wanna execute from C, you will need
to use asm or whatever instruction your compiler uses for inlining assembly
code into C.

How did you enabled HW floating point support? One thing is to enable
support in the compiler, another thing is to enable it in the operating
system, another thing is to enable it in the processor. In my combination of
compiler/processor, I have to enable support explicitly in all three
independently. Make sure you check this! You OS might crash very
indeterministically if you use FP and the OS is not set save FP registers
upon a context switch.

By the way, you are not in an interrupt, are you? I believe FP gets disabled
once you enter an interrupt.

Cheers,
-Julian


On 5/20/05, Khairul Nizam <[email protected]> wrote:
> 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 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. 


		
---------------------------------
Discover Yahoo!
 Stay in touch with email, IM, photo sharing & more. Check it out!

[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.