ArdyNT
Full Member level 2
- Joined
- Nov 6, 2012
- Messages
- 126
- Helped
- 7
- Reputation
- 14
- Reaction score
- 7
- Trophy points
- 1,298
- Activity points
- 2,304
Hi, I've built this code:
This already work well. The problem is that I need to make more than one (at least three pulses, could be PORTB.1, PORTB.2, ...) like this. The problem is my AVR only have one timer compare (timer1) and it is not found in timer0, and timer2. Is there any other way to manipulate it?
Thanks.
Code:
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
TCCR1B = 0x02;
}
// Timer1 output compare A interrupt service routine
interrupt [TIM1_COMPA] void timer1_compa_isr(void)
{
if(ldr1<=600)
{
if(OCR1A>=150)
{
OCR1A=OCR1A-100;
}
}
if(ldr1>=700)
{
if(OCR1A<=13500)
{
OCR1A=OCR1A+100;
}
}
PORTB.0 = 0; // Start the pulse
delay_us(30); // Pulse width (I know delay is not good solution to be included inside an interrupt)
PORTB.0 = 1; // Clear the pulse
TCCR1B=0x00;
}
This already work well. The problem is that I need to make more than one (at least three pulses, could be PORTB.1, PORTB.2, ...) like this. The problem is my AVR only have one timer compare (timer1) and it is not found in timer0, and timer2. Is there any other way to manipulate it?
Thanks.