ismbn
Full Member level 3
- Joined
- Feb 11, 2012
- Messages
- 160
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,308
- Location
- Mumbai. india
- Activity points
- 2,444
Hi All
I am working on AT MEGA 2560.
In My application I need to count the Pulses for the machine cycle use the 16 bit counter in the AVR.
the problem is that I am not able to configure the timer as well as counter. tried to write the code but I failed.
attaching the code so please have a look in this and tell where i am wrong
also please help we with some hint to configure the counter also........
Here is the code for timer using interrupt:
Thanks Regards
Ismail
I am working on AT MEGA 2560.
In My application I need to count the Pulses for the machine cycle use the 16 bit counter in the AVR.
the problem is that I am not able to configure the timer as well as counter. tried to write the code but I failed.
attaching the code so please have a look in this and tell where i am wrong
also please help we with some hint to configure the counter also........
Here is the code for timer using interrupt:
Code:
#include<avr/io.h>
#include<avr/interrupt.h>
int main (void)
{
// Prescaler = FCPU/1024
TCCR0B|=(1<<CS02)|(1<<CS00);
//Enable Overflow Interrupt Enable
TIMSK0|=(1<<TOIE0);
sei ();
//Initialize Counter
TCNT0=0;
DDRH=0xff;
DDRG=0xff;
PORTG=1;
while(1);;
}
char count=0;
ISR(TIMER0_OVF_vect)
{
PORTG= 0xf;
//Increment our variable
count++;
if(count==60)
{
PORTH=~PORTH; //Invert the Value of PORTC
count=0;
a==0;
}
}
Thanks Regards
Ismail