Go Down

Topic: due speed specs? (Read 1 time) previous topic - next topic

winner10920

I haven't got one yet and im debating not on getting one but how soon I want one lol, but just curious has anyone done any testing/breakdowns on the speed of common I/o actions? Like analogwrite/read digitalwrite/read as well as the new dac features
also if anyones up to it perhaps some tips on more direct ways and the different that would make

stimmer

I did do some profiling for my digitalWriteDirect function:
Code: [Select]

inline void digitalWriteDirect(int pin, boolean val){
  if(val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
  else    g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
}


void setup() {               
  pinMode(13, OUTPUT); 
  Serial.begin(9600); 
}


void loop() {
  long t;
 
  delay(1000);
  t=micros();
  for(int i=0;i<1000000;i++){
    digitalWriteDirect(13,HIGH); 
    digitalWriteDirect(13,LOW);
  }
  t=micros()-t;
  Serial.print("digitalWriteDirect : 1 million blinks in ");
  Serial.print(t);
  Serial.print(" uS = ");
  Serial.print(1000000.0/t);
  Serial.println(" MHz");
 
  delay(1000);
  t=micros();
  for(int i=0;i<1000000;i++){
    digitalWrite(13,HIGH); 
    digitalWrite(13,LOW);
  }
  t=micros()-t;
  Serial.print("digitalWrite: 1 million blinks in ");
  Serial.print(t);
  Serial.print(" uS = ");
  Serial.print(1000000.0/t);
  Serial.println(" MHz"); 
 
}


digitalWriteDirect : 1 million blinks in 107251 uS = 9.32 MHz
digitalWrite: 1 million blinks in 4682844 uS = 0.21 MHz

I think digitalWrite on the Uno was about half as fast
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

winner10920

Wow that directwrite is amazingly fast, atleast compared to a regular 328 lol, funny how much slower the regular write is, just like it is on the uno

Palliser

Here the results in my Due:

digitalWriteDirect : 1 million blinks in 107251 uS = 9.32 MHz
digitalWrite: 1 million blinks in 5135730 uS = 0.19 MHz


westfw

The current implementation of digitalWrite() for Due is pretty icky, using an Atmel-provided function that does the equivalent of both pinMode() and digitalWrite() for each call (plus the relatively significant added overhead of the additional function call.)  It's the sort of penalty you pay for putting one abstraction on top of another :-(

Given the long-time resistance of the Arduino team to speed improvements in similar areas, or to provide digitalWriteFast(), I wouldn't be inclined to expend much effort on making improvements.  But it would be nice if digitalWrite() on Due was faster than digitalWrite() on Uno, at least in a ratio similar to their clock rates.

Go Up