Razu Ahmmed
Newbie level 3
- Joined
- Jan 13, 2011
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Khulna,Bangladesh
- Activity points
- 1,307
I have faced problems in working with CTC in atmega. I can not produce interrupt after 1 second using CTC. I observed that the value of OCR1AH is not compared with with TCNT1H .What can be done?
Suggest needed.My code is following........
#include <built_in.h>
int a=0;
void Timer1compa_ISR() org IVT_ADDR_TIMER1_COMPA
{
PORTB=~PORTB;
PORTD=0xFF;
}
void main()
{
int i;
DDRB=0xFF;
DDRD=0xFF;
DDRC=0xFF;
SREG_I_bit=1;
TIMSK |= (1<<OCIE1A);
TCNT1L=0;
TCNT1H=0
i=4870;
OCR1AL=Lo(i);
OCR1AH=Hi(i);
TCCR1B |= (1<<WGM12);
TCCR1B=0x0D; /*start timer with presscaler of clk/1024*/
/*Timer/Counter1, Output Compare A Match Interrupt Enable*/
while(1)
{
PORTB=0x0F;
}
}
Suggest needed.My code is following........
#include <built_in.h>
int a=0;
void Timer1compa_ISR() org IVT_ADDR_TIMER1_COMPA
{
PORTB=~PORTB;
PORTD=0xFF;
}
void main()
{
int i;
DDRB=0xFF;
DDRD=0xFF;
DDRC=0xFF;
SREG_I_bit=1;
TIMSK |= (1<<OCIE1A);
TCNT1L=0;
TCNT1H=0
i=4870;
OCR1AL=Lo(i);
OCR1AH=Hi(i);
TCCR1B |= (1<<WGM12);
TCCR1B=0x0D; /*start timer with presscaler of clk/1024*/
/*Timer/Counter1, Output Compare A Match Interrupt Enable*/
while(1)
{
PORTB=0x0F;
}
}