Но это нифига не работает, прошу помощи.
- Код: Выделить всё
#include <ioavr.h>
#include <intrinsics.h>
int freq[] = {1132, 132, 66, 43, 32, 26, 21, 18, 16, 14, 12};
int i = 0;
void init_timer1_r(void)
{
TCCR1A = 0x00;
TCCR1B = 0x00;
TCCR1A |= (1<<COM1A0); //Режим CTC
TCCR1B = (1<<WGM12)|(1<<CS10);
OCR1A=freq[i];
}
void init_timer1_l(void)
{
TCCR1A = 0x00;
TCCR1B = 0x00;
TCCR1A |= (1<<COM1B0); //Режим CTC
TCCR1B = (1<<WGM12)|(1<<CS10);
OCR1B=freq[i];
}
void timer1_stop(void)
{
OCR1A=0;
OCR1B=0;
__delay_cycles(8000000);
}
//#pragma vector=TIMER1_COMPA_vect
int main( void )
{
DDRD = 0x00;
DDRA = 0x00;
PORTA = 0xFF;
PORTD = 0xFF;
DDRB = 0xFF;
PORTB = 0xFF;
//init_timer1_r();
__enable_interrupt();
while(1)
{
PORTB &= ~(1<<PB2);
if ((PINA & (1<<PA1)) == 0) init_timer1_r();
if ((PIND & (1<<PD1)) == 0) timer1_stop();
if ((PIND & (1<<PD0)) == 0) init_timer1_l();
if ((PINA & (1<<PA0)) == 0)
{
if (i != 10)
{
i++;
OCR1A = freq[i];
OCR1B = freq[i];
}
}
if ((PIND & (1<<PD2)) == 0)
{
if (i != 0)
{
i--;
OCR1A = freq[i];
OCR1B = freq[i];
}
}
}
}
Пишу на IAR, частота - 8 Мгц