Shop OBEX P1 Docs P2 Docs Learn Events
Why is my program so big? — Parallax Forums

Why is my program so big?

NumPyNumPy Posts: 27
edited 2013-10-22 21:35 in Propeller 1
13652 bytes sent?
There is only 32k available.

code:

/** * This is the main Measure freq program file.
*/
#include <propeller.h>
#include "simpletools.h"


int main(void)
{


int myfreq;
int pin1;


pin1=input(1);
myfreq=pulse_in(1,1);


printf("Frequency = %d",myfreq);


return 0;
}

Comments

  • photomankcphotomankc Posts: 943
    edited 2013-10-22 21:20
    printf("Frequency = %d",myfreq);

    is the culprit I'll bet. Include "simpletext.h" and replace printf with:

    putStr("Frequency = ");
    putDec(myfreq);
    putStr("\n");


    You pay a big penalty in code size for the formatting power of printf();
  • jazzedjazzed Posts: 11,803
    edited 2013-10-22 21:35
    The tutorials use print() instead of printf().

    photomankc's idea is best for smallest code.

    simpletools.h includes simpletext.h of course (and lots of other stuff too).
Sign In or Register to comment.