CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Out of ROM, A segment or the program is too large

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GiG



Joined: 03 Sep 2021
Posts: 39

View user's profile Send private message

Out of ROM, A segment or the program is too large
PostPosted: Sun Sep 26, 2021 1:14 am     Reply with quote

Hello again
I have a strange problem for a few days.
This problem occurs while compiling and just only 30% RAM and ROM occupied.
This gives me a strange error about the segment.
The problem is solved when I delete a few commands or, for example, convert Int16 to Int8 or deleting floats.
Any idea ?

Code:
>>> Warning 203 "Finally_done.c" Line 2103(1,1): Condition always TRUE
*** Error 71 "Finally_done.c" Line 2133(1,2): Out of ROM, A segment or the program is too large    set_timer
  Seg 0001E-007FF, 0392 left, need 0079C
  Seg 00800-00FFF, 0800 left, need 00808
  Seg 01000-017FF, 0800 left, need 00808
  Seg 01800-01FFF, 0800 left, need 00808
  Seg 02000-027FF, 0800 left, need 00808
  Seg 02800-02FFF, 0800 left, need 00808
  Seg 03000-037FF, 0800 left, need 00808
  Seg 03800-03FFF, 0800 left, need 00808
  Seg 00000-00002, 0000 left, need 00808 Reserved
  Seg 00003-00003, 0001 left, need 00808
  Seg 00004-0001D, 0000 left, need 00808 Reserved
  Seg 0001E-007FF, 0392 left, need 00808

      1 Errors,  1 Warnings.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 1:47 am     Reply with quote

This says what the problem is:
Quote:
0800 left, need 00808

One of your functions is too large to fit in a hardware code page
by 8 words. Split it into two functions.

If the problem function is main(), then make some of the code in
main() into one or more functions, and then call them from main().
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 6:47 am     Reply with quote

'Classic' problem, covered in the CCS C Manual, in the FAQ section. Sometimes rearanging the order of the functions as coded helps, but if one function won't fit into a memory segment, it HAS to be split up, as PCM P says.

I see a hint of ' floating point math' ( delete floats). PICs are not good at floating point math. OK, they do it, but it takes a LOT of codespace and time. You should start using 'scaled integers'. They require less code space, are more accurate and a LOT faster. So you'll get more program into a PIC, better numbers and done at warp speed !

Jay
GiG



Joined: 03 Sep 2021
Posts: 39

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 7:56 am     Reply with quote

temtronic wrote:
'Classic' problem, covered in the CCS C Manual, in the FAQ section. Sometimes rearanging the order of the functions as coded helps,but if one function won't fit into a memory segment, it HAS to be split up, as PCM P says.

I see a hint of ' floating point math' ( delete floats). PICs are not good at floating point math. OK, they do it, but it takes a LOT of codespace and time. You should start using 'scaled integers'. They require less code space, are more accurate and a LOT faster. So you'll get more program into a PIC, better numbers and done at warp speed !

Jay



Thank you I'm using integers now.
But what do you mean with "scaled integers"?!
Any way to use integers in a way that uses less memory?
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 8:09 am     Reply with quote

use 'search' here to find posting about scaled integers.

One quick example.
Say you have a 'battery guage' program. The battery voltage is 14.25. As a FP number it'll be 14.25, but as a scaled integer it'll be 14250.


Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 9:24 am     Reply with quote

and the point is that a single floating point multiplication uses many
times the code size of an integer multiplication (and time).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 3:49 pm     Reply with quote

I don't think he needs to worry about floats or scaled integers,
because (based on a previous thread) he's using a 16F1939 and
it's got 16K of ROM and he's not using most of it:
Quote:

Seg 0001E-007FF, 0392 left, need 0079C
Seg 00800-00FFF, 0800 left, need 00808
Seg 01000-017FF, 0800 left, need 00808
Seg 01800-01FFF, 0800 left, need 00808
Seg 02000-027FF, 0800 left, need 00808
Seg 02800-02FFF, 0800 left, need 00808
Seg 03000-037FF, 0800 left, need 00808
Seg 03800-03FFF, 0800 left, need 00808

7 out of 8 segments are empty. The segments are 2K each.

He just needs to break his code up into routines and call them.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sun Sep 26, 2021 11:19 pm     Reply with quote

Agreed.
After posting, I thought 'given he is only using 30%, splitting is all that
is really needed'. However as a general comment, using scaled integers is
a much better way to be working anyway... Very Happy
His big key thing is to look at the actual layout of the code, and how to
split it into smaller parts.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Oct 01, 2021 3:52 pm     Reply with quote

The PIC's memory space is like a book. You have several pages in the book but your code(function) has to fit on each page and cannot carry over to the next page. Even though your compiler says you are only using 30% of the available ROM the code that's in your Main() is too large. Try breaking your program into smaller functions that can be called individually and have the same effect.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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