Dear @saurabh pant i have done this but unfortunately i dont have a piece of work required for you as seperate code,
i am writing a seudo code i dont know whether it will help you or not , i just hope that it works to you ....
;======================================================
0rg 00h
ljmp main
out_triac bit P2.0
main :
initalize the timer0 to generate one milli second delay
initialize external interrupt
stop timer 0
setb out_traic ; assumed that clearing the bit will anable triac to conduct
sjmp $
timer_interrupt_service:
; this service routteen sould occure after one milli second or any unit that you like to sample , like you can do this for ;10usec which will cause 10ms/10usec times firing angle
if(is_delay_reached_enough)
{
stop timer0 ;
clr out_traic ;
}
iret
;=============================================
external_interrupt0_serivce_routeen:
start_timer0;
iret
;============================================
Please modify your code according to this algorithm , i hope it will definatly helps you
---------- Post added at 12:00 ---------- Previous post was at 11:48 ----------
ORG 00H //start
LJMP MAIN_1
ORG 0013H //timer subroutine for INT1
MOV TMOD,#01H //timer for to wait
MOV TL0,#67H
MOV TH0,#0FEH
SETB TR0 // start timer
JNB TF0,$
CLR TR0
CLR TF0
CLR P0.1 //this is trigger to triac
LCALL DELAY
SETB P0.1
RETI
now if i change the value of the TL0 TH0 like EE00, 8888 etc,then the bulb blinks with more delay..
plz tel me where i am going wrong....
;=================================================
this time i read your code more attentioally unlike i did before,
You are doing somthing like this
timer_interrupt_serivce:
initialize_timer;
start_timer;
waite_for_timer_to_fire_up;
enable_triac;
calling_a_delay;
disable_triac;
iret
;=============================================
You should start timer in External interrupt service routteen, so that it only starts when a zero cross occures,
and in timer service routeen you should only waite for a certain time delay , and then on the traic, and then [you can optionaly of the after a short delay, but i think its not necessory , as the reverse cycle will automatically off the triac, ]
and after that disable timer so that not further delay is possible unless the zero cross occure again