Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
int main(){int count;while(count < timeinMS){stuff stuff;count = count +1;}}
Alternately, try this:int count = -1;while (count++ < timeInMS){ DO_STUFF;}That MIGHT elliminate the double-reference to count...but if I'm not mistaken, count = count + 1 shouldn't take place in RAM anyway, although I might be giving the ATTiny more credit than it needs :-PMIKE
while (++count < timeInMS) {[...]}
Quote from: mstacho on July 16, 2011, 12:50:29 PMAlternately, try this:int count = -1;while (count++ < timeInMS){ DO_STUFF;}That MIGHT elliminate the double-reference to count...but if I'm not mistaken, count = count + 1 shouldn't take place in RAM anyway, although I might be giving the ATTiny more credit than it needs :-PMIKEYour code there is quite interesting... wouldn't a pre-increment be more like what you're looking for?Code: [Select]while (++count < timeInMS) {[...]}From what I remember, pre-incrementing in loops is slightly more efficient when processed by the compiler (jump if not zero instead of load/compare/jump) but I'm not too sure. Plus the post-increment version executes the loop an extra time xD.What happens if you replace int count with uint8_t count? (That should restrict the size of count, at least)
int main(){TimeinMS = ###while(TimeinMS--){stuff stuff;}}
static const byte GetACos[] = { 255,254,252,251,250,249,247,246,245,243,242,241,240,238,237,236,234,233,232,231,229,228,227,225, 224,223,221,220,219,217,216,215,214,212,211,210,208,207,206,204,203,201,200,199,197,196,195,193, ...
static const byte GetACos[] PROGMEM = {
AngleRad4 = pgm_read_byte(&GetACos[cos4/79]);
Things I would check include:a) How much stack space is defined, or does it simply default. Likewise do you have a heap defined...b) What if any libraries are you linked with. These can quickly eat up your space.c) do you have some static tables. Things like:Code: [Select]static const byte GetACos[] = { 255,254,252,251,250,249,247,246,245,243,242,241,240,238,237,236,234,233,232,231,229,228,227,225, 224,223,221,220,219,217,216,215,214,212,211,210,208,207,206,204,203,201,200,199,197,196,195,193, ...