Gast
#497372
static inline void _delayFourCycles(unsigned int __count)
{
if ( __count == 0 )
_asm_ __volatile__( "rjmp 1f\n 1:" ); // 2 cycles
else
_asm__ __volatile_ (
"1: sbiw %0,1" "\n\t"
"brne 1b" // 4 cycles/loop
: "=w" (__count)
: "0" (__count)
);
}
#define delay(us) _delayFourCycles( ( ( 1*(XTAL/4000) )*us)/1000 )
die delay funktion wird dann mit der Angabe der verzögerung ausgeführt.
z.b. delay(500) müssten 500µs delay sein.
Kann mir jemand erklären wie das ungefähr funktioniert.
Wenn count 0 ist dann habe ich ja alleine durch den overhead einige
cycles dabei, und somit stimmen die 2 cycles ja nicht oder?
--( ( ( 1*(XTAL/4000) )*us)/1000 ) <- was wird da genau berechnet?
bitte um eure comments!!! danke