CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Faster Division

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Richi



Joined: 15 Dec 2006
Posts: 6

View user's profile Send private message

Faster Division
PostPosted: Thu Dec 21, 2006 3:40 pm     Reply with quote

Hi Guys,
anyone an idea how I can do that faster:

output_high(OUTPUT_2);
MERKER_16_2 = MERKER_32 / MERKER_16_1;
output_low(OUTPUT_2);

I measured the time between with the Oscilloscope

16 and 32 are for long and double and this operation takes 1,1ms with a 4MHz clock!!!

Is it possible to do this faster? Some special algorytm?
I think with a the method subtraction it is not faster

Thanks
Moldy Green Bread
Guest







Re: Faster Division
PostPosted: Thu Dec 21, 2006 4:50 pm     Reply with quote

Richi wrote:
Hi Guys,
anyone an idea how I can do that faster:

output_high(OUTPUT_2);
MERKER_16_2 = MERKER_32 / MERKER_16_1;
output_low(OUTPUT_2);

I measured the time between with the Oscilloscope

16 and 32 are for long and double and this operation takes 1,1ms with a 4MHz clock!!!

Is it possible to do this faster? Some special algorytm?
I think with a the method subtraction it is not faster

Thanks


Well, 4 Mhz only gives you 1MIPS and 32 bit math on an a 8 bit MCU with no hardware multiplier is poor. If your not into writing asm
you could change your crystal to 20Mhz providing you with 5MIPS.
I assume your using a 16f series pic.
Richi



Joined: 15 Dec 2006
Posts: 6

View user's profile Send private message

PostPosted: Thu Dec 21, 2006 5:27 pm     Reply with quote

... I´m still using a PIC16F819 you meant: use a PIC18F...?

I would, but no space. Now I try to use the internal clock - 8MHz

What about the assembler? I can implement assembler code- so do you have a programm for me? I not good in assembler.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Dec 21, 2006 5:39 pm     Reply with quote

I'm not sure, but it is possible that CCS implements the division as int32/int32. Faster would be to do it as int32/int16 but it sounds logical for CCS not to provide seperate functions for all possible bit combinations (optimizing memory usage over speed).

Have a look at http://www.piclist.com/techref/microchip/math/div/index.htm for several (assembly) math routines.

Maybe a further optimization is possible for your application by using the int24/int16 routine from that same website?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Dec 21, 2006 9:02 pm     Reply with quote

Maybe you can calculate

X = 1/MERKER_16_1;

at some non-time critical point in the code. Then using this may be faster.

MERKER_16_2 = MERKER_32 * X;
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group