|
|
View previous topic :: View next topic |
Author |
Message |
louarnold
Joined: 13 May 2010 Posts: 42 Location: Ottawa, Canada
|
Help: Out of ROM. |
Posted: Wed Jul 14, 2010 6:48 pm |
|
|
This is for a PIC 16F877A with the CCS PCM C Compiler, Version 3.170b, 16412. This is a limited edition compiler.
All seemed well, and then suddenly no more ROM.
I have:
- used #separate directive
- Converted static arrays to "const";
- Taken out features to reduce the code
But still will not compile.
This software is due tomorrow (of course).
I don't see a way to attach files here.
What do I do now?
Regards,
Lou. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 14, 2010 7:42 pm |
|
|
What is the ROM usage ? Look at the top of the .LST file. The .LST file
is in your project directory after a successful compilation.
Is your ROM usage close to 2K ? Do you have a version of the compiler
that is limited to only 2K ROM ? |
|
|
louarnold
Joined: 13 May 2010 Posts: 42 Location: Ottawa, Canada
|
|
Posted: Thu Jul 15, 2010 7:51 pm |
|
|
PCM programmer wrote: | What is the ROM usage ? Look at the top of the .LST file. The .LST file
is in your project directory after a successful compilation.
Is your ROM usage close to 2K ? Do you have a version of the compiler
that is limited to only 2K ROM ? |
The deadline has passed now, but it would be handy to know how to solve this.
The following is from the last successful compile, I guess.
ROM used: 2042 (100%)
Largest free fragment is 6
RAM used: 23 (13%) at main() level
68 (39%) worst case
Stack: 5 worst case (4 in main + 1 for interrupts)
Here is the last error file:
RangeAlarm
Seg 0047-07FF, 01BD left, need 0201
Seg 0000-0003, 0000 left, need 0201
Seg 0004-0046, 0000 left, need 0201
main
Error[71] k:\lou9204\proj1v1.1\ccp_t1\proj1_pccp17.c 262 : Out of ROM, A segment or the program is too large
I really don't know in what sense the compiler is limited. I think it doesn't optimize. But the code it generates is pretty tight anyway.
Last edited by louarnold on Thu Jul 15, 2010 8:02 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 15, 2010 7:59 pm |
|
|
Quote: |
This is for a PIC 16F877A with the CCS PCM C Compiler, Version 3.170b,
ROM used: 2042 (100%)
Largest free fragment is 6
|
You have a compiler version that is limited to only 2K of ROM, instead of
the full 8K in the 16F877A. The quick solution is to use a non-limited
version of the compiler. |
|
|
louarnold
Joined: 13 May 2010 Posts: 42 Location: Ottawa, Canada
|
|
Posted: Thu Jul 15, 2010 8:06 pm |
|
|
PCM programmer wrote: | Quote: |
This is for a PIC 16F877A with the CCS PCM C Compiler, Version 3.170b,
ROM used: 2042 (100%)
Largest free fragment is 6
|
You have a compiler version that is limited to only 2K of ROM, instead of
the full 8K in the 16F877A. The quick solution is to use a non-limited
version of the compiler. |
I have one (v4), but the school has the same limited version I use now. With V4, I assume that what I compile at home will not compile the same way in school, and I need to demo each lab in school. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 15, 2010 9:51 pm |
|
|
Here is how you can make your home compiler emulate the school
compiler. Use three #org statements to block off the upper 6K of ROM
in the 16F877A, as shown below. Now it will only use the bottom 2K.
The program below, where I've used some of the floating point functions
from the CCS math.h library, uses 24% of ROM. That's 96% of the 2K
that's available. This shows that you really need to avoid using the
math.h library with your school compiler.
Code: |
CCS PCM C Compiler, Version 4.070, xxxxx 15-Jul-10 20:50
Filename: pcm_test.lst
ROM used: 1987 words (24%)
Largest free fragment is 2048
RAM used: 16 (4%) at main() level
83 (23%) worst case
Stack: 2 locations
|
Code: |
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// Prevent the full version of the CCS compiler from using
// the upper 3 ROM banks. This makes it emulate the 2K
// limited student version of the compiler, in which only
// Rom page 0 can be used (0x0000 to 0x07FF).
#org 0x0800, 0xFFF {} // Don't use Rom page 1 (2K words)
#org 0x1000, 0x17FF {} // Don't use Rom page 2 (2K words)
#org 0x1800, 0x1FFF {} // Don't use Rom page 3 (2K words)
#include <math.h>
//==========================================
void main()
{
float a, b;
printf("Hello World\n\r");
a = sin(b);
a = sqrt(b);
a = exp(b);
while(1);
}
|
|
|
|
louarnold
Joined: 13 May 2010 Posts: 42 Location: Ottawa, Canada
|
|
Posted: Fri Jul 16, 2010 1:47 pm |
|
|
That's a great idea about blocking the memory. And I didn't use the math library in this project so that isn't a problem.
Thanks for the ideas tho,
Lou. |
|
|
|
|
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
|