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 support@ccsinfo.com

PIC10F202 Out of RAM

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








PIC10F202 Out of RAM
PostPosted: Fri Aug 03, 2007 6:24 am     Reply with quote

My porject demandet a phisicaly a very small MCU, therefor I use a baseline Pic 10F202. This devise has 512 words rom and 24 byte ram. I'm programming it with the CCS PCW compiler version 4.030.

My application need almost the whole ROM and RAM capacity.

I have eight global variables they use together 13 bytes.
In two functions are local varibles witch use 6 bytes and just one function has a parameter value witch needs 2 bytes. All together I need 21 bytes.

If I open now the list file it shows the following information:
Quote:

ROM used: 483 words (94%)
Largest free fragment is 29
RAM used: 22 (92%) at main() level
23 (96%) worst case
Stack: 2 locations


I analysed the whole .lst file and checket every asm instruction witch works with register to or from witch register it writes or reads.
The Pic10F202 has from adresse 08 to 1F his general purpose register (RAM). I found out the RAM location 0A, 0B and 0C are never used. But if I define define one new varable (an int16) I get a error 74.
Quote:

***Error 74 "SenderD1_V2.c" Line 627(0,1): Not enough RAM for all variables


Strange is also the statistic sheet (.sta). There in the section Function Breakdown are all function with their resources listed. But the column RAM shows absolutely wrong values. For example a function with a locale variabel has the RAM vlueu 0. And ohter functions witch work just with global variable have the value 1. Best fits the main() function witch use 5 byte local variables, it has the value 4.
Also the ROM value are not accurate for instance the main() routine form adresse 0x087 to 0x1ED what makes 358 words is quoted with 360 words.

Has somebody else noticed similar effects? Or has someone an explonation for that.

Thanks Simon
Ttelmah
Guest







PostPosted: Fri Aug 03, 2007 8:42 am     Reply with quote

Other things need RAM. Many of the C functions, will themselves need storage, even if just to hold temporary variables. Look at the .sym file, rather than trying to use the .sta file (he latter is new, and I'd trust it as far as I could throw a 500lb weight...). The .sym file will show how the RAM is used. As it stands, the header is saying you only have one byte available, which is why declaring an int16 won't work.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 03, 2007 4:16 pm     Reply with quote

This is the type of question where you can find the answer by making
a test program. Then increasie the size of an array until you get
an error message. Then back it off by 1 element, compile, and look
at the .SYM file.

Here's the very simple test program.
Code:

#include <10F202.h>
#fuses NOWDT, NOMCLR
#use delay(clock=4000000)

// 19 chars +1 = 20 bytes
char array1[] = {"0123456789ABCDEFGHI"}; 

//==========================
void main()
{
int8 i, c;

c = array1[i];

while(1);
}


Here's the RAM usage map, from the .SYM file. It's just as Ttelmah says,
all the RAM bytes are accounted for. The 10F202 data sheet shows that
RAM addresses 0-7 are for SFR registers, and 8-0x1F are general
purpose registers.
Code:

008     @SCRATCH
009     @SCRATCH
009     _RETURN_
00A-01D array1
01E     main.i
01F     main.c
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