hi guys,
I have code here I am running on an ATmega 328p, I want to perform some math/data activity on it, for a power related project.
what I am interested in knowing is mainly, if any number crunching code makes any difference to power consumption?
I am using ca 23.5mA of current with the program listed here, I have a LED to light up once a result is known. I tried other routines but the current did not fluctuate much, if at all.
what I want to do is basically have a routine return some value, and gradually reduce the voltage into the 328p until garbage is returned, or no result.
is this possible?
I have code here I am running on an ATmega 328p, I want to perform some math/data activity on it, for a power related project.
what I am interested in knowing is mainly, if any number crunching code makes any difference to power consumption?
I am using ca 23.5mA of current with the program listed here, I have a LED to light up once a result is known. I tried other routines but the current did not fluctuate much, if at all.
what I want to do is basically have a routine return some value, and gradually reduce the voltage into the 328p until garbage is returned, or no result.
is this possible?
Rich (BB code):
void maths(){
signed char alpha, beta, gamma;
signed int prod;
signed int sum;
signed char result;
prod = (int) alpha * beta;
sum = (( signed char) (prod>>8)) + gamma;
if (sum>127)
result =127;
else if (sum < -128)
result = -128;
else
result = (signed char) sum;
int a = 1;
int b = 2;
int c = 0;
int d,e;
int i;
for(i =0; i < 10 ; i++){
a = b * c;
d*= e;
c = (a+b);
d = (a+c);
e = (a+d);
c = (a+b) * d * result;
_delay_ms(1000);
//PORTB = 0b00000010; // led on PB5
}
}