Timers in ATmega16, regsiter settings example codevision
//Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
PORTA.6=0; //STOP SIGNAL1
}
//Timer 0 overflow interrupt service routine
interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
PORTA.7=1; //START SIGNAL2
TCCR2=0x01; //START TIMER2
TCCR1B=0x00; //STOP TIMER1
}
//Timer 2 overflow interrupt service routine
interrupt [TIM2_OVF] void timer2_ovf_isr(void)
{
PORTA.7=0; //STOP SIGNAL2
}
===============================================
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 8000.000 kHz
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0xD7;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=255 ;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: 8000.000 kHz
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0xD7;
OCR2=0x00;
=======================================
// Timer(s)
TIMSK=0x45; //01000101 ALL TIMRE INTRIUPTS ARE ENANBLED
// Global enable interrupts
#asm("sei")
=============================
TCCR0=0x00; //NO CLOCK FOR TIMER0
TCCR1B=0x00; //NO CLOCK FOR TIMER1
TCCR2=0x00; //NO CLOCK FOR TIMER2
No comments:
Post a Comment