// disconnect OC0A and OC0B pins, turn on CTC mode, clk/256
TCCR0A=_BV(WGM01);
TCCR0B=_BV(CS02);
OCR0A=(F_CPU/256000);//1000Hz
#endif
for(;ms>0;ms--){
@ -61,8 +58,15 @@ void wait(int ms){
#endif
#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__)
while(!(TIFR1&(1<<OCF1A)));//wait for compare match flag
TIFR1=(1<<OCF1A);//reset flag
/* Timer1 for the masses */
# ifndef USER_TIMER0_FOR_WAIT
while(!(TIFR1&_BV(OCF1A)));//wait for compare match flag
TIFR1|=_BV(OCF1A);//reset flag
/* Timer0 for e.g. Arduino/LoL Shield */
# else
while(!(TIFR0&_BV(OCF0A)));//wait for compare match flag
TIFR0|=_BV(OCF0A);//reset flag
# endif
#else
while(!(TIFR&(1<<OCF1A)));//wait for compare match flag