|
|
View previous topic :: View next topic |
Author |
Message |
Nigel E Guest
|
Constant arrays PCWH 18F2620 |
Posted: Sat Jul 09, 2005 6:07 am |
|
|
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
|
|
Posted: Sat Jul 09, 2005 6:59 am |
|
|
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 |
|
|
|
|
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
|