likitha.b
Newbie level 5
- Joined
- Mar 4, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,370
hi,
can some one tell me what is the mistake in this code i am not getting output on cro.
interrupt service routine code for INT0
int p_rpm;//global variable.
{
int c_rpm;//current rpm
c_rpm=TCNT0;//loading the value of timer0 to current rpm
if(TOV0)
{
rpm=(TOV0*65535)+(c_rpm - p_rpm)/freq;//calculating the rpm when the time overflows.
}
rpm=(c_rpm - p_rpm)*1/freq;//freq is nothing but system clock freq defined i.e., 977hz
p_rpm = c_rpm;//equating previous rpm to current rpm
i=rpm/10;
}
main loop //for duty cycle to be displayed on the cro
while(1)
{
delay_ms(i);
turn on portb bit no 4;
delay(10-i);
turn off portb bit no 4;
}
i hv used INT0 of atmega8 at falling edge
and giving input to PD2 of portb and hv made it as pull up
for output i am using PB4 of portb made it as out and 1.
software used is code vision AVR. main objective of this code is to display the input frequency in terms of duty cycle on cro.
can some one tell me what is the mistake in this code i am not getting output on cro.
interrupt service routine code for INT0
int p_rpm;//global variable.
{
int c_rpm;//current rpm
c_rpm=TCNT0;//loading the value of timer0 to current rpm
if(TOV0)
{
rpm=(TOV0*65535)+(c_rpm - p_rpm)/freq;//calculating the rpm when the time overflows.
}
rpm=(c_rpm - p_rpm)*1/freq;//freq is nothing but system clock freq defined i.e., 977hz
p_rpm = c_rpm;//equating previous rpm to current rpm
i=rpm/10;
}
main loop //for duty cycle to be displayed on the cro
while(1)
{
delay_ms(i);
turn on portb bit no 4;
delay(10-i);
turn off portb bit no 4;
}
i hv used INT0 of atmega8 at falling edge
and giving input to PD2 of portb and hv made it as pull up
for output i am using PB4 of portb made it as out and 1.
software used is code vision AVR. main objective of this code is to display the input frequency in terms of duty cycle on cro.