2 часть
Отправлено
шпунтик_ 08 декабря 2009, г. 14:29
В ответ на:
1 часть отправлено пользователем
шпунтик_ 08 декабря 2009, г. 14:28
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();