Exact match. Not showing close matches.
PICList
Thread
'[PIC] Fitting program in memory'
2005\03\31@203338
by
Mauricio Jancic
Hi,
I need to fit a given program that I will write in C, inside 2K of
memory of a given PIC. How do you people evaluate if the program will or
will not fit on that amount of memory? (besides experience...) I mean, I can
guess it will fit, knowing the complexity of the code and what it should do,
but how can I be certain?
A program that is not working *very* well, but that has all the
required functions is consuming 1K of memory. That program was written by a
person in assembly language and, I must add, this was his first project (or
so) so it might not be as optimizet as should be.
Now, this person, wants me to do it in C, I can do it, off course,
but I'm afraid of what might happen if I run out of memory, since due to $$$
constraits I can't upgrade to the next level PIC (I'm using the 1.38 U$
PIC16F716)
Regards,
Mauricio
'[PIC] Fitting program in memory'
2005\04\01@002555
by
Matt Pobursky
|
You can't really be certain until you actually write the application but you can get a pretty good idea by writing some test code and compiling it then looking at the output. Write test routines of the
same types of operations you're likely to use in your program -- i.e.
I/O routines that read/write I/O ports, memory move and string
functions, ISR, etc.
I always do this up front when evaluating a new C compiler for a given
chip family before I even consider buying it. Every compiler has it's
own "personality" and some operations will be more efficient when
written one way over another. A good example is loops that can either
increment or decrement a loop counter -- I've seen some compilers that
generate tighter code when decrementing vs. incrementing the count.
A general rule of thumb I have used over the years is that the compiled
C code will not be more than 10-15% larger than good assembler. My
experience is that it's closer to 5-10% in practice. If it's much more
than that then you have the wrong C compiler or you haven't learned
it's "personality" yet (i.e. how to get it to produce the most
efficient object code). Code generators for modern microcontroller C
compilers have come a long way in the past 10 years. I haven't seen a
truly horrid C compiler in quite a while.
Matt Pobursky
Maximum Performance Systems
On Thu, 31 Mar 2005 22:33:37 -0300, Mauricio Jancic wrote:
{Quote hidden}> Hi,
> I need to fit a given program that I will write in C, inside 2K of
> memory of a given PIC. How do you people evaluate if the program will or
> will not fit on that amount of memory? (besides experience...) I mean, I can
> guess it will fit, knowing the complexity of the code and what it should do,
> but how can I be certain?
>
> A program that is not working *very* well, but that has all the
> required functions is consuming 1K of memory. That program was written by a
> person in assembly language and, I must add, this was his first project (or
> so) so it might not be as optimizet as should be.
>
> Now, this person, wants me to do it in C, I can do it, off course,
> but I'm afraid of what might happen if I run out of memory, since due to $$$
> constraits I can't upgrade to the next level PIC (I'm using the 1.38 U$
> PIC16F716)
>
> Regards,
>
> Mauricio
2005\04\01@011540
by
William Chops Westfield
On Mar 31, 2005, at 5:33 PM, Mauricio Jancic wrote:
> I need to fit a given program that I will write in C, inside 2K of
> memory of a given PIC. How do you people evaluate if the program will
> or
> will not fit on that amount of memory? (besides experience...) I mean,
> I can
> guess it will fit, knowing the complexity of the code and what it
> should do,
> but how can I be certain?
>
I don't think there is any way to be certain, even WITH experience,
short of already having the code written. Even in assembler, much
less C. This applies to projects that are much larger than 2k as
well; I've gone through images trying to delete features so that the
code would fit on a system with 'only' 1M, or 4M, or 16M, all too often.
You can allocate certain amounts of space to each of the modules in your
structured design (your code IS structured, right?), and then get
worried
as each piece is oversize, or gain confidence as each piece is under
size,
but for CERTAIN?
BillW
2005\04\01@015744
by
Wouter van Ooijen
> How do you people evaluate if the
> program will or
> will not fit on that amount of memory? (besides
> experience...)
What is there to trust except experience?
> I mean, I can
> guess it will fit, knowing the complexity of the code and
> what it should do,
> but how can I be certain?
of course, hard facts! just code it. no need to weed out all the bugs,
just the right 'amount' of code. and if it does not fit do check the
generated assembler, maybe you and the compiler do not understand each
other.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\04\01@015744
by
Wouter van Ooijen
> I haven't seen a
> truly horrid C compiler in quite a while.
The MCC18 compiler generates re-entrant code. A consequence is that each
local variable is allocated on a stack, which generates horrible code. I
have not found a way to switch the compiler to use a non-reentrant
pseudo-stack. You can of course declare all variables static, but that
is not as good as a static stack.
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
2005\04\01@022904
by
piclist
On Fri, 1 Apr 2005, Wouter van Ooijen wrote:
> The MCC18 compiler generates re-entrant code. A consequence is that each
> local variable is allocated on a stack, which generates horrible code. I
> have not found a way to switch the compiler to use a non-reentrant
> pseudo-stack.
Make the "overlay" storage class the default: -sco
--
John W. Temples, III
2005\04\01@065721
by
Wouter van Ooijen
> Make the "overlay" storage class the default: -sco
Thanx! Once you know the correct term it is easy to find :)
Wouter van Ooijen
-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu
More... (looser matching)
- Last day of these posts
- In 2005
, 2006 only
- Today
- New search...