Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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:
temp.jpg


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.

Latest threads

New Articles From Microcontroller Tips

Back
Top