Processing time

Status
Not open for further replies.

renzen

Member
The code:
Code:
unsigned long t1[10], t2[10];
int i,j;
void setup() {
  Serial.begin(9600);
  }
void loop() {  
  for(i=0;i<10;i++) {
  t1[i] = micros();
  j++;
  t2[i] = micros();
  }
  Serial.println("\nrun");
  for(i=0;i<10;i++) {
  Serial.print(t2[i] - t1[i]);
  Serial.print(" us\n");
  }
  delay(10000);
  j=0;
  }
Result:


Is it possible reduce the processing time below 1us?
If not possible, it's because:
- Because it's running on Arduino IDE?
or
- Because it's the total process time from: read number of microseconds - write to t1 array- read j from memory - increment j - writing j to memory - read number of microseconds - write to t2 array?
or ....?
 
I would imagine it's also the unwanted time serial printing as well?.

But 4uS times for operations in C look pretty reasonable, I also seem to recall that the uS timings aren't particularly accurate anyway?.

I 'think' the Arduino usually runs at 16Mhz?, but I've no idea how long each machine code instruction takes, but regardless you won't get many in only 4uS.
 
Hi,
I would imagine it's also the unwanted time serial printing as well?.
Uhmmm... I don't think so. Because the serial printing is not in the same loop(for i loop).


But 4uS times for operations in C look pretty reasonable, I also seem to recall that the uS timings aren't particularly accurate anyway?.
I'm not sure, but I use same method like this person who testing ADC processing time.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…