|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Out of rom question once more |
Posted: Mon Feb 05, 2007 4:10 am |
|
|
Hi
I get the "out of rom, a segment or the program is too large MAIN" error. I know this has been discussed before, the problem is my main() is as follows:
void main() {
setup();
read_freq2();
read_freq70();
read_band();
read_memorystuff();
while(1) {
trx();
}
}
Usually, according to other posts, this error was thrown when somebody had a very long main() routine. And the answer was usually to break the code up in functions. Well that's what I did, I can't break it up much further... What puzzles me is that the compiler reports the error to be on line 869 while I "only" have 867 lines of code.
If I comment trx() out in main() (not the function itself) it compiles without errors and reports rom 31%. Well trx is not too small but also not that big (100 lines in c roughly). Is it possible that, even though the compiler reports MAIN being too big, it's actually trx() which is too big, or is the problem elsewhere? Acutally I have not finished the trx() routine yet, there's more to go in there.
Additionally, with trx() not commented out, "interrupts disabled during call to prevent re-entrancy" errors are thrown, @MULFF, @ITOF, @ADDFF. These are only warnings I know, but are they a reason to worry?
Regards
Martin |
|
|
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
|
Posted: Mon Feb 05, 2007 6:21 am |
|
|
Try defining your functions with the #separate specifier in front of them. Maybe the compiler automatically makes them inline if they are called only once and main may become very large.
The problem with reentrancy is that you use float multiplication and addition and integer to float conversion in your main program, as well as in interrupts. Depending on the situation, there may or may not be problems. You will not have any interrupts while the PIC is executing those math functions. |
|
|
Guest
|
|
Posted: Mon Feb 05, 2007 10:01 am |
|
|
Thanks a lot for this tip, a #separate in front of the trx() function makes the code compile with rom 64%.
What remains are those warnings. Floating point math is called from the trx() function, that's right. In case it turns out that it is a problem that interrupts are disabled during floating point execution, what could be a solution? On the a/d interrupt I also call a function which uses floating point math, may this be the problem?
Thanks & regards
Martin |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Feb 05, 2007 11:29 am |
|
|
Quote: |
Usually, according to other posts, this error was thrown when somebody had a very long main() routine.
|
This is true but an incomplete true. The point is that the compiler canīt allocate code
in the remainig memory block, it doesnīt mater if the code is in main() or inside a long
function. May be one of the used function is too big.
The key: split it in smaller functions.
Humberto |
|
|
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
|
Posted: Mon Feb 05, 2007 12:40 pm |
|
|
Anonymous wrote: | Thanks a lot for this tip, a #separate in front of the trx() function makes the code compile with rom 64%.
What remains are those warnings. Floating point math is called from the trx() function, that's right. In case it turns out that it is a problem that interrupts are disabled during floating point execution, what could be a solution? On the a/d interrupt I also call a function which uses floating point math, may this be the problem?
Thanks & regards
Martin |
If you afford to lose some interrupts during those tens or hundreds of microseconds while the math operations take place, then it's no problem. You can avoid this by not using those math operations in interrupts, just in the main program flow and doing all computing there. |
|
|
Guest
|
|
Posted: Sat Feb 10, 2007 8:11 am |
|
|
Ok, I will keep in mind that this could be the cause if there appear to be problems with the finished code. But I think I won't change the code unless it becomes necessary. Thanks for your help.
Regards
Martin |
|
|
|
|
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
|