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

RAM and Array question

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



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

View user's profile Send private message

RAM and Array question
PostPosted: Tue Mar 23, 2004 4:54 pm     Reply with quote

In an audio sampling project I'm using PIC16F877 and PCM3.187. I have a few byte arrays with the length of MAX_CHANS which is a constant.

When I compile the code with MAX_CHANS=46 I see this in the .LST:
RAM used: 223 (62%) at main() level
269 (75%) worst case

And with MAX_CHANS=47:
RAM used: 227 (63%) at main() level
273 (76%) worst case

And MAX_CHANS=48:
RAM used: 231 (64%) at main() level
277 (77%) worst case

So far so good. But when I try to compile the code with MAX_CHANS=49 I get the infamous "Not enough RAM for all variables" error. Does anybody know why this is happening? Based on the obvious pattern, I was expecting the RAM usage to increase to 235 and 281. Why is the compiler suddenly running out of RAM? What happened to the %23 free memory?
Thanks.
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 5:22 pm     Reply with quote

Take a look at the symbol file and see how the compiler is allocating the ram on each increment of your channel count. It may be that due to the size of your arrays and the limited size of the ram in the various banks, you are running into a limit. Are you using a 2 dimensional array by any chance? This could also cause problems. Post a bit more of your code so we can learn a bit more about your problem.
Ttelmah
Guest







Re: RAM and Array question
PostPosted: Wed Mar 24, 2004 2:54 am     Reply with quote

Haplo wrote:
In an audio sampling project I'm using PIC16F877 and PCM3.187. I have a few byte arrays with the length of MAX_CHANS which is a constant.

When I compile the code with MAX_CHANS=46 I see this in the .LST:
RAM used: 223 (62%) at main() level
269 (75%) worst case

And with MAX_CHANS=47:
RAM used: 227 (63%) at main() level
273 (76%) worst case

And MAX_CHANS=48:
RAM used: 231 (64%) at main() level
277 (77%) worst case

So far so good. But when I try to compile the code with MAX_CHANS=49 I get the infamous "Not enough RAM for all variables" error. Does anybody know why this is happening? Based on the obvious pattern, I was expecting the RAM usage to increase to 235 and 281. Why is the compiler suddenly running out of RAM? What happened to the %23 free memory?
Thanks.

Page size...
The 16F877, has it's RAM split into four banks. The largest 'block' of continuous memory, is 96bytes long. You have not really run out of memory, but the array has become too large to fit into the biggest bank. The error message, is rather 'annoying', in not making this clear.
If you split the array up into two smaller arrays, it should still fit.

Best Wishes
Haplo



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

View user's profile Send private message

PostPosted: Wed Mar 24, 2004 5:17 pm     Reply with quote

Thank you for your responses. I have four arrays in my code. I was aware of the page limit, but I thought the compiler was smart enough to locate each array in a separate bank. I thought since the smallest bank is 80 bytes this would also be my array size limit. Looking the at the symbol map showed that compiler was trying to shove two of the arrays in bank 2 (96 bytes), and that's why I couldn't make the array sizes bigger than 48.

Now I'm using the #locate preprocessor to put the arrays at 0x20, 0xA0, 0x110 and 0x190, and everything is fine. Any reason I shouldn't be doing this? Thanks.
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