inline void waitms(unsigned int i) { /* Wait approximatly i milliseconds based on FOSC clock*/ unsigned int j = 0; const int k = (unsigned int)(FOSC / 4000); asm volatile ( "clr __tmp_reg__" "\n\t" "or __tmp_reg__, %A0" "\n\t" "or __tmp_reg__, %B0" "\n\t" "breq L3%=" "\n\t" "L1%=:" "\n\t" "mov %A1, %A2" "\n\t" "mov %B1, %B2" "\n\t" "L2%=:" "\n\t" "sbiw %1,1" "\n\t" "brne L2%=" "\n\t" "sbiw %0,1" "\n\t" "brne L1%=" "\n\t" "L3%=:" "\n\t" :: "w" (i), "w" (j), "r" (k) ); }