Re: How to strip a tiny avr?




Tim Wescott wrote:
Mike Noone wrote:

linnix wrote:

We are looking to do a simple project with the tiny 15/25/45/85.
Tiny15 would be ideal. However, to compile a simple dummy C program
with AVR studio/WinAVR created 2.8K, which would rule out the 15 and
25. Are there ways to strip the run time library?


I expect you're using some large library function, either printf,
scanf, or some floating point stuff, or something of that nature.

Nothing like that at all, no floating points. Floating points would
pull in 3K at least.


How about actually posting the code you're trying to shrink rather than
trying to get us to read your mind?


Just the follow 2 routines take up over 1K. I guess tiny15 is
definitely out. I think I will go with the tiny45.

int adc(int channel, int ref)
{
int i, t, tt = 0;

if(ref == AVCC)
ADMUX = (1<<REFS0) | channel; // internal AVCC
else
ADMUX = (1<<REFS1) | channel; // internal 1.1

ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0); // set ADC prescaler
to , 1MHz / 8 = 125kHz

//do a dummy readout first
ADCSRA |= (1<<ADSC); // do single conversion
while(!(ADCSRA & 0x10)); // wait for conversion done, ADIF flag
active

for(i=0;i<8;i++) // do the ADC conversion 8 times for
better accuracy
{
ADCSRA |= (1<<ADSC); // do single conversion
while(!(ADCSRA & 0x10)); // wait for conversion done, ADIF
flag active

t = ADCL; // read out ADCL register
t += (ADCH << 8); // read out ADCH register

tt += t; // accumulate result (8 samples) for later
averaging
}

ADCSRA = 0;
ADMUX = 0;

tt >>= 4; // average the samples

return(tt);
}

char n[32];
char o[32];
char c[32];

remap(int code)
{
int i,j;

for(i=0; i<32; i++)
o[i] = n[i];

switch(code)
{
case 'y':
n[0]=1; n[1]=2; n[2]=2; n[3]=1; n[4]=2; n[5]=2; n[6]=1; n[7]=2;
break;
case 'p':
n[0]=1; n[1]=3; n[2]=3; n[3]=3; n[4]=1; n[5]=3; n[6]=3; n[7]=3;
break;
case 'g':
n[0]=2; n[1]=3; n[2]=2; n[3]=3; n[4]=2; n[5]=3; n[6]=2; n[7]=3;
break;
case 'r':
n[0]=1; n[1]=2; n[2]=1; n[3]=3; n[4]=1; n[5]=2; n[6]=1; n[7]=3;
break;
case 'b':
n[0]=3; n[1]=1; n[2]=3; n[3]=3; n[4]=3; n[5]=2; n[6]=3; n[7]=3;
break;
}

for(i=0; i<8; i++)
{
n[i+8] = n[i];
n[i+16] = n[i];
n[i+24] = n[i];
}

for(i=0; i<3200; i++)
{
j = i/100;
if(j < 32)
{
c[j] = n[j];
}
}
}

.



Relevant Pages