Update,
GPIO-Routine für Arduino Mega testweise optional ersetzbar durch low-level Register bit read/write:
Code:
//--------------------------------------------
int32_t test_GPIO_AVR() { // 6,000,000 GPIO bit r/w
volatile static bool w=false, r;
uint32_t y;
for (y=0; y<2000000; y++) {
bitWrite(PORTB, PB5, w);
w=!w;
r = bitRead(PINB, PB7);
bitWrite(PORTB, PB6, w&!r); // optional: bitWrite(PORTB, PB6, w&r);
}
return 1; // debug
}
Code:
6a 41569 GPIO digitalRead/Write
6b 4528 GPIO register bitRead/Write
Anm.:
direct port manipulation compiles to 1 or 2 instructions, calling digitalRead is dozens.
One issue to be aware of is interrupts - some of the native direct-port manipulation code will not be
interrupt-safe, where as digitalRead/digitalWrite/pinMode() are carefully coded to work when used
both in an ISR and the main program.
Update 2:
Habe jetzt auch die Routine für optional 32bit fp_op (float) neu geschrieben, die dadurch jetzt auch erhebliche Laufzeitunterschiede zu 64bit double auf allen ARM-Cores erkennen lässt!
Lesezeichen