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 support@ccsinfo.com

Can main() break the 2K barrier??

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







Can main() break the 2K barrier??
PostPosted: Fri Nov 16, 2001 5:15 pm     Reply with quote

I am now running into ROM constraints.
My project uses the PIC 16F877 chip

I have tried to break up my code into as many functions as possible. The functions take up apx 1 and a 1/2 of the (2K) block sections.

The problem is that my main() code which is mostly "if" statements and funtion calls has taken up 95\% of the space in the third block (0x1000 - 0x17FF). The fourth block is still empty.

As I add code to main() is crashes. Does anyone know a way around this limitation?

Thanks, John Goss
___________________________
This message was ported from CCS's old forum
Original Post ID: 1163
Dale Botkin
Guest







Re: Can main() break the 2K barrier??
PostPosted: Fri Nov 16, 2001 9:12 pm     Reply with quote

:=The problem is that my main() code which is mostly "if" statements and funtion calls has taken up 95\% of the space in the third block (0x1000 - 0x17FF). The fourth block is still empty.
:=
:=As I add code to main() is crashes. Does anyone know a way around this limitation?

Just an idea, but... if your main() is mostly code that gets executed in line, could you make arbitrary chunks of it into functions and just call them sequentially? The down side is that you may have to make more variables global if they're used by more than one of the chunks, but it might help.

Dale
(obviously still self-learning C, I know...)
___________________________
This message was ported from CCS's old forum
Original Post ID: 1168
Tomi
Guest







Re: Can main() break the 2K barrier??
PostPosted: Sat Nov 17, 2001 8:26 am     Reply with quote

Have you tried to use the #separate directive?
The CCS C is good enough and the PIC has limited stack space so if you try to brake your code e.g.:

void MyFunc()
{
.........
}

void main()
{
........
MyFunc();
.......
}

The compiler will translate your function as INLINE (the main() size is not affected).


:=I am now running into ROM constraints.
:=My project uses the PIC 16F877 chip
:=
:=I have tried to break up my code into as many functions as possible. The functions take up apx 1 and a 1/2 of the (2K) block sections.
:=
:=The problem is that my main() code which is mostly "if" statements and funtion calls has taken up 95\% of the space in the third block (0x1000 - 0x17FF). The fourth block is still empty.
:=
:=As I add code to main() is crashes. Does anyone know a way around this limitation?
:=
:=Thanks, John Goss
___________________________
This message was ported from CCS's old forum
Original Post ID: 1171
John Goss
Guest







Re: Can main() break the 2K barrier??
PostPosted: Mon Nov 19, 2001 10:08 am     Reply with quote

Tomi & Dale,

Thanks for the ideas. Yes my code is executed inline. Over the weekend I came up with the same idea as you did Dale. I will seperate my main code into two seperate functions and then call the two functions in main() this should allow the code to locate properly in two blocks of code space.

Thanks, again

John



:=:=The problem is that my main() code which is mostly "if" statements and funtion calls has taken up 95\% of the space in the third block (0x1000 - 0x17FF). The fourth block is still empty.
:=:=
:=:=As I add code to main() is crashes. Does anyone know a way around this limitation?
:=
:=Just an idea, but... if your main() is mostly code that gets executed in line, could you make arbitrary chunks of it into functions and just call them sequentially? The down side is that you may have to make more variables global if they're used by more than one of the chunks, but it might help.
:=
:=Dale
:=(obviously still self-learning C, I know...)
___________________________
This message was ported from CCS's old forum
Original Post ID: 1229
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