View previous topic :: View next topic |
Author |
Message |
Guest
|
Bizzare compiler error message |
Posted: Thu Mar 15, 2007 8:35 am |
|
|
I have the following code at the beginning of my program:
#define wait delay_ms(100)
I use it and it compiles just fine until the 12th or so instance. I am then told I am out of ROM. But I'm not. If I comment out any one of the instances, I find that I am at the 40% point of ROM use. When I remove the comment symbols from that one instance, I get the error.
The code is for the 16F877A and I use PCW Version v3.190
Is there a buffer limit in the compiler for repeated uses of such code?
If I add other code, I get no error messages and it compiles just fine. |
|
|
Ttelmah Guest
|
|
Posted: Thu Mar 15, 2007 10:55 am |
|
|
There is no limit of this type. However there is a limit on how much code can form one 'piece' (the bank size of the chip), try adding the extra delays in a series of subroutines. I suspect ifyou look at the symbol file on the '40%' version, you will find the routine containing the delays, is close to the bank limit.
Best Wishes |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Thu Mar 15, 2007 2:28 pm |
|
|
The memory, in each PIC, is organized like a blank book with dividers already placed in it. You can write whatever you want into each section but once that section is full you must start writing in another section. One problem is that you can't simply carry over into the next section. If the topic, that you are writing about, won't fit into the section that you've been writing to then you have to start writing into a different section.
If a function is too large to fit into one bank(section) then it must be split up into smaller portions so they can fit somewhere. The functions cannot bleed over the physical bounderies of the bank.
As you keep adding the wait's the function is getting bigger until you have run out of ROM for that bank.
Ronald |
|
|
Guest
|
|
Posted: Sat Mar 17, 2007 12:18 pm |
|
|
I fixed the problem. Dunno why it happened.
When I rebooted the computer the next day, I redid the compile and the problem had disappeared.
Al |
|
|
ThomasC
Joined: 09 Oct 2007 Posts: 62
|
|
Posted: Fri Nov 09, 2007 3:42 pm |
|
|
What is considered a "section"? I am encountering the same problem. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 09, 2007 4:15 pm |
|
|
The same problem ?
He had a quirky problem where it failed after 12 compilations.
Quote: | I use it and it compiles just fine until the 12th or so instance |
He fixed it by re-installing the compiler.
If you have a problem with "out of rom", then post:
1. Your PIC.
2. The compiler version. |
|
|
ThomasC
Joined: 09 Oct 2007 Posts: 62
|
|
Posted: Fri Nov 09, 2007 4:38 pm |
|
|
Sorry, I have the same error message, but the usual problem. The segment appears to be full. How can I move it to another segment. I have already broken the routine down so it contains one subroutine.
I am using a PIC16F690 and PCM 4.060. Thanks! |
|
|
ThomasC
Joined: 09 Oct 2007 Posts: 62
|
|
Posted: Fri Nov 09, 2007 4:55 pm |
|
|
it says 99% ROM usage and I'm at 820 words. The max is 800 words for this pic correct? |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Nov 09, 2007 4:59 pm |
|
|
A 'section' is like an 8x11.5 piece of paper. You might have four pieces of paper to write your program on.
Let's say you have your main() and you have written all of your code in it. As you enter more code inside of main() that page gets filled up until you run out of space. Now, instead of having all of your code in main() you could take a portion of it, maybe something like displaying data on a LCD screen, and make a routine from it called display(). In main() you remove all of the code that you just made display() from and replace it with the function call display();. You have, now, reduced the amount of code on your first page that contains main() and display() is now written on the second piece of paper. The program sill works but it has been spread out withing the rom of the PIC.
Clear as mud?
Ronald
Edit:
You zipped in there just before I replied. If your rom is 99% full then you will need to slim your code down or move to a PIC that has more memory. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 09, 2007 5:21 pm |
|
|
Try the test program shown below. I compiled it with PCM vs. 4.060
and it used 95% of the ROM space. It says it used 3909 words.
3909 / 4096 = .95
That's correct.
Code: |
CCS PCM C Compiler, Version 4.060, xxxxx 09-Nov-07 15:11
Filename: 16F690_Test.lst
ROM used: 3909 words (95%)
Largest free fragment is 139
RAM used: 23 (9%) at main() level
87 (34%) worst case
Stack: 3 locations |
Code: | #include <16F690.h>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B5, ERRORS)
#include <math.h>
//==========================
void main()
{
float a;
float b;
float result;
a = 123.456789;
b = 456.789012;
result = a + b;
result = a - b;
result = a * b;
result = a / b;
result = (a + b) - (a * b);
result = floor(a);
result = pow(a, b);
result = cos(a);
result = asin(a);
//result = atan(a);
//result = atan2(a, b);
result = log(a);
result = sqrt(a);
//printf("%f ", result);
while(1);
} |
|
|
|
ThomasC
Joined: 09 Oct 2007 Posts: 62
|
|
Posted: Mon Nov 12, 2007 8:48 am |
|
|
rnielsen wrote: | A 'section' is like an 8x11.5 piece of paper. You might have four pieces of paper to write your program on.
Let's say you have your main() and you have written all of your code in it. As you enter more code inside of main() that page gets filled up until you run out of space. Now, instead of having all of your code in main() you could take a portion of it, maybe something like displaying data on a LCD screen, and make a routine from it called display(). In main() you remove all of the code that you just made display() from and replace it with the function call display();. You have, now, reduced the amount of code on your first page that contains main() and display() is now written on the second piece of paper. The program sill works but it has been spread out withing the rom of the PIC.
Clear as mud?
Edit:
You zipped in there just before I replied. If your rom is 99% full then you will need to slim your code down or move to a PIC that has more memory.
Ronald
|
Ronald - Clear =) Now I know that creating another segment is just calling a function instead of embedding the whole thing in the main function.
PCM - I tried the program and it shows 95% of the rom used, just like you said. Why does it say 3909 words when the word count is actually only around 100 words? I have 700+ words in my program and it still builds successfully. Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 12, 2007 12:40 pm |
|
|
Quote: | Why does it say 3909 words when the word count is actually only around 100 words? |
It's referring to the ROM memory where the program is stored, not to
the source code.
In computers, a 'word' means a binary value that's larger than a byte.
Each ROM location in a 16F-series PIC takes up 14 bits. They are not
8-bits in size, so they can't be referred to as 'bytes'. Therefore, it's
the custom to refer to them as "words".
Quote: |
it says 99% ROM usage and I'm at 820 words. The max is 800 words for this pic correct? |
So now your original post becomes clear. It was a misunderstanding.
Your actual ROM word usage is approximately 4055 words. (.99 x 4096)
The 16F690 has 4096 ROM words available.
To answer your question, you need to reduce your code size or change
to a PIC with more ROM. I suspect that you have a lot of floating point
code in your program. Try removing that code if possible. |
|
|
|