bmandl
Full Member level 4
![Full Member level 4](/styles/images/ranks/flevel1.gif)
Hello,
in my project, I want to use timerone library for timer interrupt. First, the external interrupt (zero cross detector) calls interrupt subrutine in which I set timer overflow interval, set timer interrupt subrutine and start the timer. When timer overflow interval expires, interrupt subrutine start in which I just turn on and turn of my TRIAC, but then I need to stop timer and detach interrupt in this interrupt subrutine, but it seems that is not possible, because timer never stops and is always on. Also, in my interrupt subrutine (from zero cross), where I set timer interval, this interval does not make any changes. Interval is always same (some predefined value).
Can anyone help me with my problem? Is usage of timerone library only possible in main program and not in interrupt subroutines?
External interrupt called by zero cross detector:
Timer1 interrupt called by timer one:
in my project, I want to use timerone library for timer interrupt. First, the external interrupt (zero cross detector) calls interrupt subrutine in which I set timer overflow interval, set timer interrupt subrutine and start the timer. When timer overflow interval expires, interrupt subrutine start in which I just turn on and turn of my TRIAC, but then I need to stop timer and detach interrupt in this interrupt subrutine, but it seems that is not possible, because timer never stops and is always on. Also, in my interrupt subrutine (from zero cross), where I set timer interval, this interval does not make any changes. Interval is always same (some predefined value).
Can anyone help me with my problem? Is usage of timerone library only possible in main program and not in interrupt subroutines?
External interrupt called by zero cross detector:
Code:
void ISR_Triac()
{
Timer1.setPeriod(zak_isr);
Timer1.attachInterrupt(Triac_ON);
Timer1.restart();
}
Timer1 interrupt called by timer one:
Code:
void Triac_ON()
{
digitalWrite(TRIAC,HIGH);
digitalWrite(TRIAC,LOW);
Timer1.stop();
}