// disconnect OC0A and OC0B pins, turn on CTC mode, clk/256
111clk/1024
TCCR0A=_BV(WGM01);
*/
TCCR0B=_BV(CS02);
//TCCR2 = 0x0D; //CTC Mode, clk/128
OCR0A=(F_CPU/256000);//1000Hz
//OCR2 = (F_CPU/128000); //1000Hz
#endif
TCCR1B=(1<<WGM12)|4;//CTC Mode, clk/256
OCR1A=(F_CPU/256000);//1000Hz
for(;ms>0;ms--){
for(;ms>0;ms--){
@ -61,8 +58,15 @@ void wait(int ms){
#endif
#endif
#if defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__) || (__AVR_ATmega1284P__) || defined (__AVR_ATmega1284__)
#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
/* Timer1 for the masses */
TIFR1=(1<<OCF1A);//reset flag
# 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
#else
while(!(TIFR&(1<<OCF1A)));//wait for compare match flag
while(!(TIFR&(1<<OCF1A)));//wait for compare match flag