|
|
View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
Not enough Ram in 18F2455 |
Posted: Sun Feb 03, 2008 3:46 pm |
|
|
I'm using a 18F2455 with a bunch of arrays declared like this:
int8 message40[39]={A,l,space,back,l,space,y,o,u,r,space,b,a,s,e,s,space,a,r,e,space,b,e,l,o,n,g,space,t,o,space,u,s,space,ENTER,execute};
This is the 40th one I declared. With the first 39 the compiler says I have used 24% of Ram. The first 39 are of similar size. When I add the 40th I get "not enough Ram error".
Why would 39 take 24% and the next put me over the limit? It is an 18 series part so I should not need the *16 for pointers correct? All my declarations are in a function, I tried moving the 40th to the top of the code to make it Global but that did not help.
Any ideas?
Thanks
Ringo _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 03, 2008 3:58 pm |
|
|
1. What is your compiler version ?
Quote: | int8 message40[39]={A,l,space,back,l,space,y,o,u,r,space | 2. Are the arrays really declared like that ?
Individual ASCII characters are normally declared in single quotes.
As shown above, they are not characters, they're symbols. You would
need a #define statement for each symbol. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Sun Feb 03, 2008 4:01 pm |
|
|
They are all in #defines already.
Everything works perfectly up until #40. All the others are very similar. What I'm sending is the Keycodes, so A is actually a 4, and Space is a 40, etc.
They all work up until I hit the memory problem. _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 03, 2008 4:17 pm |
|
|
But what is the compiler version ? |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Sun Feb 03, 2008 4:49 pm |
|
|
4.007 _________________ Ringo Davis |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 03, 2008 5:23 pm |
|
|
I made the test program shown below and compiled it with vs. 4.007.
Each array takes 39 bytes. That's 38 bytes of text and 1 byte for the
string terminator (0x00). The total ram usage is:
Quote: | 39 bytes x 40 arrays = 1560 bytes. |
The percentage usage is:
Quote: | (1560 bytes / 2048 total RAM) * 100 = 76 % |
There are 6 bytes more, as reported in the .LST file, which undoubtedly
are assigned to scratch variables. But 76% is correct.
Code: |
CCS PCH C Compiler, Version 4.007, xxxxx 03-Feb-08 15:12
Filename: PCH_Test.lst
ROM used: 6152 bytes (25%)
Largest free fragment is 18424
RAM used: 1566 (76%) at main() level
1566 (76%) worst case
Stack: 0 locations
|
Code: |
#include <18F2455.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
int8 message01[39] = {"High-Current Sink/Source: 25 mA/25 mA "};
int8 message02[39] = {"Four Timer modules (Timer0 to Timer3) "};
int8 message03[39] = {"Up to 2 Capture/Compare/PWM (CCP) modu"};
int8 message04[39] = {"Capture is 16-bit, max. resolution 5.2"};
int8 message05[39] = {"Compare is 16-bit, max. resolution 83."};
int8 message06[39] = {"PWM output: PWM resolution is 1 to 10-"};
int8 message07[39] = {"Enhanced Capture/Compare/PWM (ECCP) mo"};
int8 message08[39] = {"Master Synchronous Serial Port (MSSP) "};
int8 message09[39] = {"supporting 3-wire SPI (all 4 modes) an"};
int8 message10[39] = {"10-bit, up to 13-channel Analog-to-Dig"};
int8 message11[39] = {"module (A/D) with Programmable Acquisi"};
int8 message12[39] = {"Dual Analog Comparators with Input Mul"};
int8 message13[39] = {"C Compiler Optimized Architecture with"};
int8 message14[39] = {"100,000 Erase/Write Cycle Enhanced Fla"};
int8 message15[39] = {"Self-Programmable under Software Contr"};
int8 message16[39] = {"8 x 8 Single-Cycle Hardware Multiplier"};
int8 message17[39] = {"In-Circuit Debug (ICD) via two pins "};
int8 message18[39] = {"Optional dedicated ICD/ICSP port (44-p"};
int8 message19[39] = {"Wide Operating Voltage Range (2.0V to "};
int8 message20[39] = {"Flash/Data EEPROM Retention: > 40 year"};
int8 message21[39] = {"Supports Control, Interrupt, Isochrono"};
int8 message22[39] = {"Supports up to 32 Endpoints (16 bidire"};
int8 message23[39] = {"On-Chip USB Transceiver with On-Chip V"};
int8 message24[39] = {"Streaming Parallel Port (SPP) for USB "};
int8 message25[39] = {"Four Crystal modes, including High Pre"};
int8 message26[39] = {"Two External Clock modes, up to 48 MHz"};
int8 message27[39] = {"8 user-selectable frequencies, from 31"};
int8 message28[39] = {"User-tunable to compensate for frequen"};
int8 message29[39] = {"Secondary Oscillator using Timer1 @ 32"};
int8 message30[39] = {"Dual Oscillator options allow microcon"};
int8 message31[39] = {"USB module to run at different clock s"};
int8 message32[39] = {"Allows for safe shutdown if any clock "};
int8 message33[39] = {"Information contained in this publicat"};
int8 message34[39] = {"applications and the like is provided "};
int8 message35[39] = {"and may be superseded by updates. It i"};
int8 message36[39] = {"ensure that your application meets wit"};
int8 message37[39] = {"Microchip products meet the specificat"};
int8 message38[39] = {"Microchip believes that its family of "};
int8 message39[39] = {"intended manner and under normal condi"};
int8 message40[39] = {"Note the following details of the code"};
//====================================
void main()
{
while(1);
} |
|
|
|
|
|
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
|