Re: FPU problem urgent

Khairul Nizam <[email protected]>
Newsgroups gmane.comp.hardware.motorola.microcontrollers
Message-ID <[email protected]>
dear julian
 
I have tried what you told me to do....i didnt use any OS.just running simple fp culculation.I have enabled FP at the compiler,CW.
But the same problem still occurs,the debugger stop at the assembly line instruction during debung session.
When I use the disassembler function....some weird things heppens.the assembly command i wrote was replace by an invalid opcode (0x00000000)....no wonder the debugger stop at taht instruction.so what should i do now?
 
maybe someone can suggest me something,maybe from metrowerks also....
 
the disassembly from CW....this two lines give me problems.....(function: asm void fpuaku())
----------------------------------------------------------------------------------------------------------------
  mfmsr r3;
003FA000: 3FF00000  addis    r31,r16,0
  ori r3,r3,0x2002;
003FA004: 00000000  dc.l     0x00000000               ; Invalid opcode '....'
  mtmsr r3;
003FA008: 7C600124  mtmsr    r3
  
  mtfsb1 29;
003FA00C: FFA0004C  mtfsb1   29
003FA010: 4E800020  blr

-------------------------------------------------------------------------------------------
 
for your reference ...below are the real c code that i wrote.
 
 
 
#include "mpc555.h"
asm void fpuaku(void)   //the function for above disassembly 
{
 
  mfmsr r3;
  ori r3,r3,0x2002;      //enable fp
  mtmsr r3;
  
  mtfsb1 29;               //disable iEEE mode
}
void main()
{
 
 float ordinate;
 float AtoD,i=0;
 float table_x;
 float max_AtoD;
 
 fpuaku();
 
 AtoD=104;
 table_x=10;
 max_AtoD=1024;
 
 ordinate=(AtoD*table_x)/max_AtoD; 
    ordinate=ordinate + 1.0;
 
 
 while (1) { i++; }   // loop forever
}

regards
nizam

Julian Requejo <[email protected]> wrote:
The documentation is a bit tricky, because this is not in the MPC555 manual,
but rather in the PowerPC documentation. If you wanna learn more about FP
unit look at this doc. However, you will likely get confused. It is not easy
reading, but it is worth glacing over to get an idea. Keep in mind that this
is powerPC in general. Some aspects, like FP square root is not supported by
the MPC555.

The basic steps are as follows:
- Enable FP
   
mfmsr r3
ori   r3,r3,0x2002
mtmsr r3

- If IEEE model is not required, disable it.
mtfsb1  29

- When compiling, tell your compiler that you want floating point. For Diab,
you do this with
-tPPC555EH:simple

- If you are using a preemptive OS, there should be some option to tell the
OS that you are using FP. This will force the OS to save FP registers upon a
context switch.

- If inside an interrupt, re-enable FP as described above. You shouldn't do
FP inside an ISR anyway.

- FP vars are 32 or 64 bits. So if you have many of them, make sure to
allocate enough stack!

Besides this, I don't think you need to do much more to get FP working.
Someone else please contribute if I am missing something.
Cheers and happy FP,
-Julian


-----------------------------------------------------------
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!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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