![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Einly
Joined: 10 Sep 2003 Posts: 60
|
How to increase array size? |
Posted: Wed Nov 17, 2004 4:54 am |
|
|
Dear all,
I am trying to create an array of 1024 bytes, and I get a "subscript out of range" error. I am using PIC16f876 with pcm compiler 2.73. After that I decrease the size and finally successfully compile it when the array size is 64 bytes. I then tried to create 2 more arrays with each 64 bytes and I got this error "Not enough RAM space".
May I know:
1) What should I do to use a large array, e.g. until 2048 bytes? Without the 2 errors? e.g. By changing the chip/ compiler?
e.g.
byte TX_Buffer[2048];? _________________ Einly |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: How to increase array size? |
Posted: Wed Nov 17, 2004 5:14 am |
|
|
Einly wrote: | Dear all,
I am trying to create an array of 1024 bytes, and I get a "subscript out of range" error. I am using PIC16f876 with pcm compiler 2.73. After that I decrease the size and finally successfully compile it when the array size is 64 bytes. I then tried to create 2 more arrays with each 64 bytes and I got this error "Not enough RAM space".
May I know:
1) What should I do to use a large array, e.g. until 2048 bytes? Without the 2 errors? e.g. By changing the chip/ compiler?
e.g.
byte TX_Buffer[2048];? |
The 'Not enough RAM space' error, with the smaller arrays, probably implies you have not got '#device *=16' added at the start of the code. Without this, the compiler will only access the first bank of RAM, making for smaller code, but limiting your RAM space.
The maximum array size on '16' chips is 128bytes. This is because of the 'banked' nature of the RAM I/O.
You can 'simulate' a larger array, using the read_bank, and write_bank functions, by reserving a large area of memory, and writing a 'wrapper' function to split the required address into a bank and the address in the bank.
Even with this done, the 16F876, only has 368bytes of RAM in total, and you can reckon that perhaps 50 of these locations will be needed for system storage...
You could update to a '18' family chip, and this then allows larger arrays, and in some cases a lot more RAM available. However even here, really large RAM areas, are reserved for the biggest chips.
You could consider using an external 'FRAM' memory as storage for an array.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
jfahlman Guest
|
subscript out of range |
Posted: Mon Jan 17, 2005 8:12 pm |
|
|
I just ran into the same problem when trying to create a const int16 array[256] and got the subscript out of range (using 16f876a). Two arrays of 128 size will work but is a pain. Anyone have any ideas? I just started compiling with the PCM today
This is a constant array thus in program memory so I do not see the need for the 128 limit for RAM paging.
FYI the 256 word array is for a fast CRC lookup table. |
|
![](templates/subSilver/images/spacer.gif) |
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
Re: subscript out of range |
Posted: Mon Jan 17, 2005 10:52 pm |
|
|
jfahlman wrote: | I just ran into the same problem when trying to create a const int16 array[256] and got the subscript out of range (using 16f876a). Two arrays of 128 size will work but is a pain. Anyone have any ideas? I just started compiling with the PCM today
This is a constant array thus in program memory so I do not see the need for the 128 limit for RAM paging.
FYI the 256 word array is for a fast CRC lookup table. |
Your array is 2*256=512 bytes. According to CCS manual: "ROM arrays may not occupy more than 256 locations.".
Also read the last post here:
http://www.ccsinfo.com/forum/viewtopic.php?t=21501 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|