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

PIC12F509 ram error ?

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



Joined: 01 Jul 2007
Posts: 37

View user's profile Send private message

PIC12F509 ram error ?
PostPosted: Fri Aug 17, 2007 2:21 pm     Reply with quote

Hi,

pcw 4.050
pic12F509

When I compile the following 'do nothing' program, the compiler returns the 'not enough ram for all variables' error.
I do only define a 25 byte variable while the PIC do have 41 bytes ( as shown in the "device selector" tool )

Is it possible to update the component definition ? I did not find the RAM size tab in the component editor

Code:
#include <12f509.h>
#fuses INTRC, NOWDT, NOMCLR, NOPROTECT
#use delay(clock=4000000)
#use fast_io(B)

void main ( void ) {
   unsigned int8 COUNTER[25];
}


Thanks,
Dimmu
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 2:45 pm     Reply with quote

I was able to make it compile with the array size set to 22.
Some of the RAM is being used for scratch variables.

Read Ttelmah's post about scratch variables in this thread (2nd post):
http://www.ccsinfo.com/forum/viewtopic.php?t=27996

At the end of this thread Metalm was going to (I think) contact CCS
to ask them how to re-locate the scratch variables to another place
in the RAM memory map. But he never posted the results.
http://www.ccsinfo.com/forum/viewtopic.php?t=31580
Dimmu



Joined: 01 Jul 2007
Posts: 37

View user's profile Send private message

PostPosted: Sat Aug 18, 2007 2:15 am     Reply with quote

This is not the same problem I have. The PIC12F509 has 41 bytes of RAM :
0x07 to 0x1F in bank 0
0x30 to 0x3F in bank 1

CCS uses 2 bytes of scratch RAM + 1 byte for return ( see map file )
It looks like CCS do only manage 25 bytes of RAM for that pic while it have actually 41.
Note.: I have the same problem if I define 2 variables of 12 bytes each ( in order to avoid the bank overflow )

here is the map file :
Code:
007     @SCRATCH
008     @SCRATCH
008     _RETURN_
00A-01F main.COUNTER

0002  main
0002  @cinit

Project Directory:
    c:\program files\picc\projects\12f509_demo\

Project Files:
    simple_test.c
    ..\..\devices\12f509.h

Units:
    c:\program files\picc\projects\12f509_demo\simple_test.c (main)

Compiler Settings:
    Processor:      PIC12F509
    Pointer Size:   5
    Opt Level:      0
    Short,Int,Long: UNSIGNED: 1,8,16
    Float,Double:   32,32
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 18, 2007 2:43 am     Reply with quote

To enable use of the upper bank of RAM, you need to add the #device
statement shown below in bold. Then you can have two arrays, one
of 21 bytes and the other of 16 bytes (maximum).
Quote:
#include <12f509.h>
#device *=8
#fuses INTRC, NOWDT, NOMCLR, NOPROTECT
#use delay(clock=4000000)
#use fast_io(B)

void main ( void )
{
unsigned int8 COUNTER[21];
unsigned int8 array[16];

}
Dimmu



Joined: 01 Jul 2007
Posts: 37

View user's profile Send private message

PostPosted: Sat Aug 18, 2007 2:54 am     Reply with quote

Thank you !

Dimmu
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