S.P.S
Member level 5
- Joined
- Oct 30, 2011
- Messages
- 89
- Helped
- 19
- Reputation
- 38
- Reaction score
- 19
- Trophy points
- 1,298
- Location
- Thodupuzha, India, India
- Activity points
- 1,742
hi,
i am doing a project in atmega32.
i am using timer0 as counter and timer 2 as timer with an 8 mhz crystal. i have an interrupt routine which wakes every 10 ms.
prescalar is set to 1024 for timer 2 and loaded a value for 10 ms delay and i count up to 1000 interrupts for a 10s delay.
but when i simulate the program i got the serial output after 33s which is expected to be 10s.serial routine and the interrupt routine works good .
what can be the reason
i am posting my code
i am using atmel studio6,winavr and proteus
i havn't tested it on hardware
please help me,
thanks in advance
i am doing a project in atmega32.
i am using timer0 as counter and timer 2 as timer with an 8 mhz crystal. i have an interrupt routine which wakes every 10 ms.
prescalar is set to 1024 for timer 2 and loaded a value for 10 ms delay and i count up to 1000 interrupts for a 10s delay.
but when i simulate the program i got the serial output after 33s which is expected to be 10s.serial routine and the interrupt routine works good .
what can be the reason
i am posting my code
Code:
#include <avr/atmega32.h>
#include <avr/interrupt.h>
unsigned char beat,temp;
unsigned int cnt=0;
int main(void)
{
uart_init();
TCNT0=0;
TCNT2=178;
TCCR2=0x07;
TCCR0=0x06;
TIMSK=0x40;
sei ();
while(1);
}
ISR (TIMER2_OVF_vect)
{
cnt++;
if(cnt==1000)
{
uart_tx(TCNT0);
TCNT2=178;
TCNT0=0;
cnt=0;
}
}
i am using atmel studio6,winavr and proteus
i havn't tested it on hardware
please help me,
thanks in advance