irfan ahmad
Full Member level 3
- Joined
- Feb 17, 2012
- Messages
- 181
- Helped
- 54
- Reputation
- 108
- Reaction score
- 54
- Trophy points
- 1,318
- Location
- LAHORE PAKISTAN
- Activity points
- 2,212
i wat to use these interrupts at same time
1; timer0.
2; timer1,
3; external interrupt int0,
i have just enable two interrupts TIMER0 AND TIMER1 but malfunctioning.
if i enable only one interrupt timer0 or 1 then it works fine.
But when i enable both then only timer0 interrupt works.
here is my code.
please guide me .
1; timer0.
2; timer1,
3; external interrupt int0,
i have just enable two interrupts TIMER0 AND TIMER1 but malfunctioning.
if i enable only one interrupt timer0 or 1 then it works fine.
But when i enable both then only timer0 interrupt works.
here is my code.
Code:
#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
#include "avr/interrupt.h"
int main(void)
{
DDRC=0XFF;
PORTC=0X00;
DDRB=0XFF;
PORTB=0X00;
_delay_ms(100);
////////////////////////TIMER FOR PWM CALCULATION
TCCR1A=0X00; //NORMAL MODE
TCCR1B=0X01; // NO PRESCALER
TCNT1H=0XC1; //
TCNT1L=0X80;
TIMSK=1<<TOIE1;
////////////////////////////////
TCNT0=0X06; // initial value
TCCR0=0X03; //TIMER0 CONTROL REGISTER
//TIMSK=1<<TOIE0; when i comment this line then only timer0 works
////////////////////////////////
sei(); // ENABLE GLOBAL INTERRUPT
while(1);
}
//////////////////////////////////PWM
ISR(TIMER1_OVF_vect)
{
TCNT1H=0XC1;
TCNT1L=0X80;
PORTB=~PORTB;
}
///////////////////////////
ISR (TIMER0_OVF_vect)
{
TCNT0=0X06; // TIMER COUNTER REGISTER
PORTC=~PORTC;
}
please guide me .