Interrupts and delay()
hi, started to program attiny85 using following core hlt:
http://highlowtech.org/?p=1695
as far know not support tone() function so, in attempt make own created following sketch:
code: [select]
void setup()
{
pinmode(0, output);
}
void loop()
{
mytone(500);
delay(1000);
mynotone();
delay(1000);
}
isr(timer1_compa_vect)
{
portb ^= (1 << portb0);
}
void mytone(int freq)
{
float period = 1.00/(float)freq;
float ticks = (125000.00*(float)period)/2.00;
int on = ticks/255;
tccr1 = (1 << ctc1) | (1 << cs12); // divide 8 prescaler
ocr1a = ticks; //
ocr1c = ticks; //
timsk = (1 << ocie1a) | (1<<toie1);
sei();
}
void mynotone()
{
tccr1 = 0;
tcnt1 = 0;
}
everything works fine, however, when running sketch delays between tones aren,t 1000ms
if knows why happens, please let me know. thanks.
everything works fine, however, when running sketch delays between tones aren,t 1000ms
if knows why happens, please let me know. thanks.
so how long delay instead of expected 1000ms?
and same length?
...r
Arduino Forum > Using Arduino > Programming Questions > Interrupts and delay()
arduino
Comments
Post a Comment