tnx.
Let me explain the flow,
1) at start falling ZC has detected-timer value loaded for 2 ms overflow interrupt & timer set ON - value at dimmerdelay[0]=0 updated (say dimmerspeed[0]=0, so (5-5=0) //
Code:
dimmerdelay[0]=(DIMMER_MAX-dimmerspeed[0])<<1;
-edge changed for next half cycle.
As the timer ISR first time call from this loop and dimmerdelay[0] has 0 value, so does not need to wait for timer overflow and will process timer1 ISR.
2) UNDER timer1Isr(), ELSE block will run only and triac fired and we will get full brightness.
3) suppose if dimmerspeed[0] is updated other than ZERO(say 1)
as per my timer 2 ms overflow interrupt and in 5 step dimmer,
first timer1Isr() execute from INTF ISR
Code:
if(dimmerdelay[0])
{
DIMMER_1=1;
if(!(dimmerdelay[0]&0x8000))// if dimmerdelay[0] otherthan ZERO ALWAYS TRUE until dimmerdelay[0] comes to ZERO.
dimmerdelay[0]--;
and value of dimmerdelay[0] will 0 - timer1 verflow after 2 ms and AFTER 1 overfow execute the ELSE block and tric will fired.
Code:
}else
{
DIMMER_1=0;
dimmerdelay[0]=0xFFFF;
}
and dimmerdelay[0] array loaded value to prevent further firing within this half cycle.
tnx