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

Constant arrays PCWH 18F2620

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







Constant arrays PCWH 18F2620
PostPosted: Sat Jul 09, 2005 6:07 am     Reply with quote

I am having trouble with generating a const array of int8 in PCH for the 18F2620. Is there a limitation on array size ie is it an 8 bit or other function?

If I declare int8 const array[1024]={d,d,d,d,d,....d}; then it compiles fine but: 1) a constant [index] to this array yeilds value [index+1] : 2) a computed index e.g. [a*b] yeilds a totally different result - the correct one if the result is <255.

Is there a better or alternative way of generating a large i.e. 1k to 4k lookup table as a work around - can the compiler generate large arrays - It works fine with RAM arrays but then there is never enough of that on the devices !!! :-)) hint hint Microchip!
Ttelmah
Guest







PostPosted: Sat Jul 09, 2005 6:59 am     Reply with quote

Of course it'll yield index+1. C uses zero referenced arrays. The first entry in a C array is entry 0.

What are the 'types' of 'a', and 'b'?. Remember that if you multiply two integers (which default to 8 bits), you will be using 8bit arithmetic.
If you want to access an element using a computed result from integers, then force them to be treated as int16. So
array[(int16)a*(int16)b]

will force 'a' and 'b' to be converted into longs before the arithmetic, and then the arithmetic will be performed in int16.

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