@RubaSon:
Ich habe mal den wichtigen Teil rauskopiert:
Code:
_pulse_in5:
  ;@genus(9)                          ; THIS FOR 10 US UNITS but approx. depends on XTAL

  ; you can remove the above call and tailor this routine
  ; when remarked 10 cycles/ loop are needed and for 1 Mhz this is 10 uS
  ; for 4 MHz you need additional 30 cycles and the @genus can be used
  ; --------------------------------------------------------------------
  ; routine adapted for 4 MHz (30 cycl.):
  Push r17                            ; 2 cycl.
  Ldi r17,$08                         ; waiting 24 cycl.

_pulse_in6:
  Dec r17
  brne _pulse_in6
  nop                                 ; 2 cycl.
  nop
  Pop r17                             ; 2 cycl.
  ; --------------------------------------------------------------------
  ; routine adapted for 8 MHz (70 cycl.):
  ;Push r17                            ; 2 cycl.
  ;Ldi r17,$16                         ; waiting 66 cycl.

;_pulse_in6:
  ;Dec r17
  ;brne _pulse_in6
  ;Pop r17                             ; 2 cycl.
  ; --------------------------------------------------------------------
  Ld r0,z                             ; 2 cycl. get pin state
  And r0, r24                         ; 1 cycl. get only the input pin state
  Eor r0,r16                          ; 1 cycl. xor with begin state returns zero if the same
  Brne _pulse_in_exit                 ; 2 cycl. ready ,state changed
  Adiw xl,1                           ; 2 cycl. counter
  brne _pulse_in5                     ; 2 cycl. again
Die Warteschleife braucht selbst 10 Zyklen, darin muss man dann die Zeit totschlagen. Ich habe mal 2 Schleifen mit 30 bzw. 70 Zyklen für 4 MHz und 8MHz eingefügt. Du müßtest natürlich je nach deinem Quarz weniger Zyklen einfügen, wenn du nur 4µs haben willst.

Gruß Dirk