tiny85, 1МГц
при выходе из процедуры Beep(1250) выбрасывает на первую строчку после main?
void Beep(unsigned int tone)
{
if (tone == 0)
{
TCCR0A=0x00;
TCCR0B=0x00;
TCNT0=0x00;
}
else
{
TCCR0A=0x00; // normal mode for timner, normal port operation
TCCR0B=0x02; // clkI/O/8 (From prescaler)
TCNT0=0xF5; // 10 time = FF-0A = F5
OCR0A=0x00;
OCR0B=0x00;
}
}
int main(void)
{
//unsigned int i=0;
// initialisation
set_bit(DDRB, LED);
set_bit(DDRB, Transistor);
set_bit(DDRB, SPEAKER);
// timer
TIMSK = (1<<TOIE0); // enable overflow interrupt
sei();
while(1){
//set_sleep_mode(SLEEP_MODE_PWR_DOWN);
Beep(1250);
_delay_ms(100);
Beep(0);
}
return 0;
}