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

How to increase array size?

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

How to increase array size?
PostPosted: Wed Nov 17, 2004 4:54 am     Reply with quote

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
Ttelmah
Guest







Re: How to increase array size?
PostPosted: Wed Nov 17, 2004 5:14 am     Reply with quote

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
jfahlman
Guest







subscript out of range
PostPosted: Mon Jan 17, 2005 8:12 pm     Reply with quote

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 Smile

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.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

Re: subscript out of range
PostPosted: Mon Jan 17, 2005 10:52 pm     Reply with quote

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 Smile

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