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 problem

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








RAM problem
PostPosted: Mon Jan 17, 2005 2:19 pm     Reply with quote

I have attached my code snippet with this mail. While I compile this code, the compiler says "NOT ENOUGH RAM FOR ALL VARIABLES". Is there anyway, to overcome this problem, without reducing the number of variables and using the same PIC. Suggestions are pl. welcome.

Thanks
Karthik

Code:
#include <16f873.h>  // 2k byte ROM, 128 byte EEPROM

#device *=16 adc=10

#fuses XT,NOWDT,NOPROTECT,NOWDT,NOLVP, NOBROWNOUT, NOPUT

#use delay(clock=4000000)

#use rs232(baud=9600, parity=N, bits=8, xmit=PIN_C6, rcv=PIN_C7, errors)



#include <string.h>

#include <stdlib.h>



long int Tedslength;

long int hall=0,illum=0,ADCInput=0;

int channel;



#rom 0x0A00 ={0x01,0x03,0x02,0x01,0x01,0x04,0x0A,0x0C}                                         

#rom 0x0A10 ={0x0B,0xC5,0x15,0x4E,0xC1,0xF4,0xED,0xAE,0x60,0x09,0x01,0x01,0x08,0x02,0x00,0x00}

#rom 0x0A20 ={0x01,0x03,0x02,0x02,0x01,0x08,0x01,0x01}                                         

#rom 0x0A30 ={0x09,0x0E,0x00,0x01,0x80,0x80,0x80,0x80,0x80,0x82,0x80,0x80,0x80,0x01,0x01,0x01}

#rom 0x0A40 ={0x01,0x03,0x02,0x02,0x01,0x08,0x01,0x01}                                         

#rom 0x0A50 ={0x09,0x0E,0x00,0x01,0x80,0x80,0x80,0x80,0x80,0x82,0x80,0x80,0x80,0x02,0x02,0x02}

#rom 0x0A60 ={0x01,0x03,0x02,0x02,0x01,0x08,0x01,0x01}                                         

#rom 0x0A70 ={0x09,0x0E,0x00,0x01,0x80,0x80,0x80,0x80,0x80,0x82,0x80,0x80,0x80,0x03,0x03,0x03}

#rom 0x0A80 ={0x01,0x03,0x02,0x02,0x01,0x08,0x01,0x01}                                         

#rom 0x0A90 ={0x09,0x0E,0x00,0x01,0x80,0x80,0x80,0x80,0x80,0x82,0x80,0x80,0x80,0x04,0x04,0x04}

#rom 0x0AA0 ={0x01,0x03,0x02,0x02,0x01,0x08,0x01,0x01}                                         

#rom 0x0AB0 ={0x09,0x0E,0x00,0x01,0x80,0x80,0x80,0x80,0x80,0x82,0x80,0x80,0x80,0x05,0x05,0x05}

#rom 0x0AC0 ={0x01,0x03,0x02,0x03,0x01,0x11,0x11,0x2D}                                         

#rom 0x0AD0 ={0x49,0x45,0x45,0x45,0x2D,0x31,0x34,0x35,0x31,0x2E,0x32,0x2D,0x53,0x54,0x49,0x4D}


unsigned char bp_timer;      // bp signal timer(1khz)

unsigned char bp_byte;      // bp signal status

char lcd1, lcd2, lcd3;      // display characters

int32 MSB,LSB;

int cnt=0,ct=0; // cnt is the count for LSB

//ct is the count for sending the LSB count value to the EM04



char Map3[11] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x00};
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 17, 2005 2:35 pm     Reply with quote

I don't see enough variable declarations in your snippet to cause a
problem with RAM usage.

I think there must be some variables that you are not showing us.
I suspect that you have some large arrays or structures somewhere.
Remember that the 16F873 has limited RAM, compared to a 16F877.
Also, I did a test program, and the largest array size that I could
make was 95 bytes.
Guest








RAM problem
PostPosted: Thu Jan 20, 2005 4:47 pm     Reply with quote

Thanks for the information.
I am actually not permitted to paste the entire code here. But I would like to know, is there any other factor other than global variables, such as number of functions used and number of interrupts created needs RAM. A reply would be really helpful, to find the real cause of the problem.
Thanks
Karthik
Ttelmah
Guest







Re: RAM problem
PostPosted: Fri Jan 21, 2005 10:53 am     Reply with quote

Anonymous wrote:
Thanks for the information.
I am actually not permitted to paste the entire code here. But I would like to know, is there any other factor other than global variables, such as number of functions used and number of interrupts created needs RAM. A reply would be really helpful, to find the real cause of the problem.
Thanks
Karthik

Every variable uses RAM. However the RAM is 'reused', if the function containing it, cannot occur inside another function. So (for instance), if you declare a group of variables at the start of 'main', these will all use RAM. Then you call another function that uses variables, it too will use RAM for each of these. If inside this, you call another function, it's RAM useage will also be added. However if you then return to the main, and call a second function, any RAM it uses, can come out of the area used by the earlier subroutines, _unless they contain 'static' variables, in which case these locations are protected).
If you then have an interrupt, any variables it uses, are 'on top' of the main ones.
Global memory, is on top of the total 'pool' needed by all the functions.
The memory useage is available to you, by looking at the .sym file, or selecting to view the 'symbol map' from PCW. Compile a smaller program, and look at how the variables use memory.
Remember also, that the area needed for arrays, must be contiguous, so some re-use may be prevented if these are large.
On top of all this, there is a massive area needed to hold all the main registers when entering an interrupt (typically perhaps 26bytes on a 18 chip, and a little less on the 16 chips), and a 'scratch' area needed for some arithmetic (particularly fp arithmetic).

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