i am trying to write a program for at89c4051 uc which uses nested interrupts but its not working at all. My aim is to control some leds and relays using extrnal hardware interrupt pins ..when int0 is there then say mains supply is present and when int1 gets activated then mains supply is not there and depending on the interrupt certain leds and relays need 2 b swtchd on and off.
is it possible to forever nest the interrupts in an infinite loop? viz. when int0 is working i hav chnged the priority to set int1 high so dt int0 can b interrupted( which i vry much need) and in the isr for int1 i hav chnged priority again to set int0 high so that when suddenly mains supply comes back anothr set of instructions is executed( i need 1 interrupt to be able to interrupt the other)
the code is as follows.................
org 00h
ljmp main
org 30h
main:
mov ie,#85h ; to enable ea and int0 and int1
mov p1,#06h ; port 1.1 and p1.2=i/p and p1.0-p1.7 hav o/p devices(led and relay)
mov sp,#50h ; just felt like defining sp
d: nop ; main routine loops indefinitely
sjmp d
org 0003h ; isr0
ljmp bat0
reti
org 0013h ; isr1
ljmp bat1
reti
org 0ccc3h ; isr0
bat0: mov ip,#04h ; set the int1 interrupt high priority
mov ie,#85h ; enabled interrupts again
pop 03h ; to prevent stack from overflowing
pop 05h
clr p1.6 ; clear the led/relay which wud be set by isr1
setb p1.5 ; swtch on led/relay for isr0
l1: mov r0,#255 ; delay routine
l2: mov r2,#255
l3: mov r4,#255
l4: mov r5,#255
djnz r4,l4
djnz r2,l3
djnz r0,l2
nop
reti
org 0ffc0h ;isr1
bat1:
mov ip,#03h ; change interrupt priority 2 make int0 high
mov ie,#85h ; enabled interrupts again
pop 03h ; prevent stack ovrflow
pop 05h
setb p1.6 ; set led/relay for isr1
clr p1.5 ; clear devices set by isr0
; need a delay again for 30 mins at this point, not attaching code here
reti
end
this code shud let me set up infinite nested loop structure, evrytime 1 isr is executing it shud waiting for some time 4 another interrupt 2 happen if it does then the corrsponding isr shud run and if during that isr again while its waiting in the delay routine the other interrupt shud happen then jump to isr for that interrupt and so oon...but its not working....i am simulating in proteus and evrytine the program seems to be stuck in the delay part. even if the other interupt happens still until the currnt isr ends its full delay routine it is not jumping to the other isr, not acknowledging interrupt. i dnt kno how this happens only after the delay is over does the execution strt frm the other isr. why isnt the control being transferred the instant the othr interrupt happnes???????????? why is the delay routine always being executed fully??
do i need the reti instructions in the isr's ??? if i do not put reti instruction in the isr codes' and instead put an infinite loop there evn then during the excution of the loop the other interrupt is not being acknowledged...in that it nevr gets acknowledged plzzzzzzzzzzzzzzzzzzzzz helppppp me with this rubbish someone!!!!!! im a nooob
is it possible to forever nest the interrupts in an infinite loop? viz. when int0 is working i hav chnged the priority to set int1 high so dt int0 can b interrupted( which i vry much need) and in the isr for int1 i hav chnged priority again to set int0 high so that when suddenly mains supply comes back anothr set of instructions is executed( i need 1 interrupt to be able to interrupt the other)
the code is as follows.................
org 00h
ljmp main
org 30h
main:
mov ie,#85h ; to enable ea and int0 and int1
mov p1,#06h ; port 1.1 and p1.2=i/p and p1.0-p1.7 hav o/p devices(led and relay)
mov sp,#50h ; just felt like defining sp
d: nop ; main routine loops indefinitely
sjmp d
org 0003h ; isr0
ljmp bat0
reti
org 0013h ; isr1
ljmp bat1
reti
org 0ccc3h ; isr0
bat0: mov ip,#04h ; set the int1 interrupt high priority
mov ie,#85h ; enabled interrupts again
pop 03h ; to prevent stack from overflowing
pop 05h
clr p1.6 ; clear the led/relay which wud be set by isr1
setb p1.5 ; swtch on led/relay for isr0
l1: mov r0,#255 ; delay routine
l2: mov r2,#255
l3: mov r4,#255
l4: mov r5,#255
djnz r4,l4
djnz r2,l3
djnz r0,l2
nop
reti
org 0ffc0h ;isr1
bat1:
mov ip,#03h ; change interrupt priority 2 make int0 high
mov ie,#85h ; enabled interrupts again
pop 03h ; prevent stack ovrflow
pop 05h
setb p1.6 ; set led/relay for isr1
clr p1.5 ; clear devices set by isr0
; need a delay again for 30 mins at this point, not attaching code here
reti
end
this code shud let me set up infinite nested loop structure, evrytime 1 isr is executing it shud waiting for some time 4 another interrupt 2 happen if it does then the corrsponding isr shud run and if during that isr again while its waiting in the delay routine the other interrupt shud happen then jump to isr for that interrupt and so oon...but its not working....i am simulating in proteus and evrytine the program seems to be stuck in the delay part. even if the other interupt happens still until the currnt isr ends its full delay routine it is not jumping to the other isr, not acknowledging interrupt. i dnt kno how this happens only after the delay is over does the execution strt frm the other isr. why isnt the control being transferred the instant the othr interrupt happnes???????????? why is the delay routine always being executed fully??
do i need the reti instructions in the isr's ??? if i do not put reti instruction in the isr codes' and instead put an infinite loop there evn then during the excution of the loop the other interrupt is not being acknowledged...in that it nevr gets acknowledged plzzzzzzzzzzzzzzzzzzzzz helppppp me with this rubbish someone!!!!!! im a nooob