| ??? 12/05/00 13:10 Read: times |
#6984 - RE: High level interrupt |
Hi all,
please look at my code example: http://www.specs.de/~danni/training/reti.a51 It demonstrate 2 things: 1. It is possible. 2. But it is better to use it not in practice. I found also no reason to need it really. Especially, since I prefer C programming. Peter ;************************************************************************ ;* * ;* test program to understand the 8051 interrupt logic * ;* * ;* Author: Peter Dannegger * ;* danni@specs.de * ;* * ;************************************************************************ test equ 070h ;counter to demonstrate working it0_progress equ 0 ;interrupt status flag it0_done equ 8 ie0_done equ 10h ie0_simulate equ 18h ;force high level interrupt ;during low level interrupt no_2reti equ 20h ;force incomplete killing ;of the low level interrupt jmp main org 3 ;ie0 interrupt jmp int_e0 org 0Bh ;t0 interrupt clr ea ;start no interruptable code ! jmp int_t0 int_t0: push acc push psw setb it0_progress setb ea ;now high level interrupts allowed jnb ie0_simulate, int_t0_1 clr ie0_simulate setb int0 ;simulate external interrupt clr int0 int_t0_1: nop ;do something nop clr ea ;must be not interruptable setb it0_done kill_int_t0: clr it0_progress pop psw pop acc setb ea reti int_e0: push psw push acc nop ;do something nop pop acc pop psw setb ie0_done jnb it0_progress, int_e0_2 ;kill it0 by correcting the stack and execute a 2. reti dec sp ;remove return address to it0 dec sp jb no_2reti, int_e0_1 ;force wrong return ! call int_e0_2 ;call reti int_e0_1: clr ea jmp kill_int_t0 int_e0_2: reti main: mov r0, #7Fh main1: mov @r0, #0 ;clear RAM djnz r0, main1 mov tmod, #00000010b ;t0: 8 bit reload mov th0, #128 mov tl0, th0 mov tcon, #00010001b ;start t0, ie0 edge triggered mov ip, #00000001b ;int ex0 high prioriuty mov ie, #10000011b ;enable interrupts ;wait until it0 done jnb it0_done, $ clr it0_done mov test, #1 ;force ex0, wait until done setb int0 ;simulate external interrupt clr int0 jnb ie0_done, $ clr ie0_done mov test, #2 ;wait until it0 done, force ie0 interrupting it0, kill it0 setb ie0_simulate jnb ie0_done, $ clr ie0_done ;it0_done not set, since it0 killed mov test, #3 ;wait until it0 done jnb it0_done, $ clr it0_done mov test, #4 ;wait until it0 done, force ie0 interrupting it0, kill it0, ;return incomplete ! setb no_2reti setb ie0_simulate jnb ie0_done, $ clr ie0_done clr it0_done mov test, #5 mov p1, test ;forever: p1 = 5 ;wait until it0 done jnb it0_done, $ ;since wrong returned, next lines are never reached ! clr it0_done mov test, #6 mov p1, test ;never: p1 = 6 jmp $ end |



