Just wanted to clarify some pretty basic Arduino concept:
If I put this code into an arduino board:
double start, endTime;
long int counter = 0;
void setup()
{
Serial.begin(19200);
start = micros();
}
void loop()
{
endTime = micros();
counter++;
//Point A
if((endTime - start) > 1000000)
{
Serial.println(counter);
counter = 0;
start = micros();
}
}
...I see >38000 value in my serial monitor (for the 'counter' variable).
However, the moment I put in some heavy calculation in 'Point A', the value drops to 150 - 170. This is expected, I guess.
My question is: Is the only way to push up the operational frequency lies in optimising the code/calculation? Or, is there some other way I can get faster execution?