Hi,
Iam using TIMER2_COMPA_vect Interrupt in my arduino program.
Iam counting the number of pulses in INT0 pin using INT0 interrupt . Whenever count reaches a particular value, it resets the value and turn a boolean true.
In my loop program iam checking this boolean variable and want to produce pulses(4 or more) of some fixed pulse width. Iam calling the following function if the boolean variable is true.
void pulseGenerator()
{
cli();
TCNT2 = 0;
TCCR2B |= 0x82;
TIMSK2 |= (1 << 1);
sei();
}
Iam also wrote the ISR for output compare match interrupt as follows.
ISR(TIMER2_COMPA_vect)
{
if(checkAverage_ > average_)
{
TCCR0B = 0x80;
checkAverage_ = 1;
}
else
{
checkAverage_++;
digitalWrite(pwmPin, HIGH);
}
}
But my problem is whenever i enable the output compare match interrupt the whole system hangs. If i disable the interrupt it will work fine. Only Output Compare match interrupt A is causing hanging problem while all other interrupts are working fine.
Can any one help me on this.
Regards,
Jerry