|
Код создан ICCAVR Application Builder.
В симулятолре AvrStudio программа выполняется, но на обработчик прерывания никак не хочет переходить. Перепробовал все варианты с PWM и без - ничего не получается. C Timer0 все работает.
Если у меня в программе что-то не так, то где ошибка?
//ICC-AVR application builder : 07.02.2005 19:56:55
// Target : T2313
// Crystal: 11.059Mhz
#include void port_init(void) //TIMER1 initialize - prescale:1 #pragma interrupt_handler timer1_compb_isr:13 //call this routine to initialize all peripherals MCUCR = 0x00; //
E-mail:
info@telesys.ru
#include
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x18;
PORTD = 0x00;
DDRD = 0x00;
}
// WGM: 1) PWM 8bit Phz correct, TOP=0x00FF
// desired value: 1Hz
// actual value: 21684,312Hz (100,0%)
void timer1_init(void)
{
TCCR1B = 0x00; //stop timer
TCNT1H = 0xFF; //set count value
TCNT1L = 0x01;
OCR1AH = 0x00; //set compare value
OCR1AL = 0xFF;
OCR1BH = 0x00; //set compare value
OCR1BL = 0x5F;
TCCR1A = 0x11;
TCCR1B = 0x01; //start Timer
TCCR1C = 0x00; // Timer/Counter1 Control Register C
ICR1H = 0x00; // Input Capture Register 1
ICR1L = 0xFF; // Input Capture Register 1
}
void timer1_compb_isr(void)
{
//compare occured TCNT1=OCR1A
}
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer1_init();
GIMSK = 0x00;
TIMSK = 0x20;
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void)
{
init_devices();
//insert your functional code here...
for(;;)
{
} // for(;;)
} // main
Ответы