View previous topic :: View next topic |
Author |
Message |
Dimmu
Joined: 01 Jul 2007 Posts: 37
|
PIC12F509 ram error ? |
Posted: Fri Aug 17, 2007 2:21 pm |
|
|
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
|
|
Posted: Fri Aug 17, 2007 2:45 pm |
|
|
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
|
|
Posted: Sat Aug 18, 2007 2:15 am |
|
|
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
|
|
Posted: Sat Aug 18, 2007 2:43 am |
|
|
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
|
|
Posted: Sat Aug 18, 2007 2:54 am |
|
|
Thank you !
Dimmu |
|
|
|