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 support@ccsinfo.com

Largest array size?

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







Largest array size?
PostPosted: Mon May 18, 2009 8:49 am     Reply with quote

I'm attempting to create a scaled sinewave lookup table and it must be very precise. However, everytime I try to compile, the compiler hangs (100% CPU utilisation) attempting to parse the array. The array consists of 32768 16-bit integers.

I believe this should be possible on a 18f PIC, but CCS does not seem to like the size of the array. Any suggestions?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 18, 2009 11:46 am     Reply with quote

Break it up into two or more smaller arrays.
Ttelmah
Guest







PostPosted: Mon May 18, 2009 12:23 pm     Reply with quote

Also though, do consider using something better.
As it stands, a 16bit array is only going to give 16bit accuracy at the best. Now for 0 to 5 degrees, you can get this accuracy by simple linear multiplication. Even for the larger angles linear interpolation will give this accuracy for much less space. Using 65KB, for a solution seems wasteful.
There was a rather nice 15bit solution posted as part of an application note some time ago, which used just seven terms, and a handful of machine instructions. A web search should find it.
Are you 'dead sure', you have the maths limits on your array sizes really well done?. A 65KB array ought to work (if you look at how the code is done, it should handle this), but if you overflowed by even one entry it'd fail.
Are you really using a step size of just 0.0027 degree per entry?. If not, and the array actually corresponds to the full circle, remember that sin's for 90 to 180 degrees (or the equivalent in any other angular unit), are the same as for 90 to 0 degrees, while those for the other two quadrants can just be generated by inversion.

Best Wishes

Best Wishes
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