Square root

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

Square root

2,822 Views
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Posted: Mon Feb 28, 2005 2:26 pm    
 
Hello,
I´m on a new project. I have to apply the Pitagoras Theorem with float variables. I have tested the program on HC908AP, but it seems to be very slowly. I have not experience with HC912 at all.
Do you know how long does it take to calculate that? A first aprox. will be helpful.

Thank you,
 
Posted: Mon Feb 28, 2005 6:35 pm
 
Upload your code and someone will run it through the codewarrior S12 compiler/simulator and give a cycle count.
 
Posted: Wed Mar 02, 2005 1:15 pm    
 
Code:
float g; unsigned char x; unsigned char y; . . . g=sqrtf(x*x+y*y); . . . 

 
that´s all.
 
Posted: Wed Mar 02, 2005 10:59 pm  
 
Hi, I 've tried it in a GP32 and it takes aprox. 15.000 cycles to perform the operation given x=120 & y=200. If your bus is 8MHZ it would give you more than 500 calculations / sec. Confused

But if you want top speed, you can make a bidimensional table of .... Rolling Eyes lets say... 256*256*2 Razz Shocked , well, actually you only need 128*256*2=64K Very Happy

Saludos
 
Posted: Fri Mar 04, 2005 1:00 pm    
 
Hi,

S12 will do the float calculation in 4818 cycles. Older S12s run at 25MHz, new S12X runs at 40MHz. That is ~5200 calculations/s on S12 and ~8300 calculations/s on S12X. The float library for S12 I have is done in C, not in assembly, so it would be possible to improve it a great deal by optimizing the sqrt and multiplication functions.

S12 is not the best core for float as it has no direct support for 32bit operations and no coprocessor for floats either.

Posted: Mon Mar 07, 2005 12:01 pm    
 
Hello,

yes polosoft, it´s a big table, I know.

Thank you Daniel, and everyone for the replies.

bye,
Labels (1)
0 Kudos
0 Replies