Demonstrating hardware interrupts with 7segment display.Download contains the source code with proteus simulation file.
Sponsored Links
Circuit Diagram
Assembly CodeCode (Text):
ORG 00H JMP MAIN ORG 03H ;INT0 interrupt subroutine starting address JMP EXT0 ;Interrupt subroutine ORG 13H ;INT1 interrupt subroutine starting address JMP EXT1 ;Interrupt subroutine ORG 30H MAIN: MOV IE,#10000101B ;INT0,INT1 Interrupt Enable MOV IP,#00000010B ;INT1 Interrupt Priority MOV TCON,#00000001B ;INTO is falling edge trigger MOV SP,#70H ;Set stack pointer MOV R2,#00 ;Count initial value setting CLR P1.7 ; ;-------------------------------------------------- LOOP: MOV A,R2 ;Remember to read decimal values MOV P2,A ;Show JMP LOOP ;Cycle EXT0: PUSH ACC ;The stack PUSH PSW ; MOV A,R2 ; ADD A,#01H ;Count pointer plus 1 DA A ;Do decimal adjustment MOV R2,A ;Into R2 MOV P2,A ; ; CALL DELAY1 ;Delay POP PSW ;The stack POP ACC ; RETI ;Interrupt return ;----------------------------------------------- EXT1: PUSH ACC ;The stack PUSH PSW ; SETB P1.7 ; CALL DELAY2 ;Delay CLR P1.7 ; POP PSW ;The stack POP ACC ; RETI ;Interrupt return ;----------------------------------------------- DELAY1: MOV R5,#200 ;Delay process D11: MOV R6,#100 ; D21: MOV R7,#248 ; DJNZ R7,$ ; DJNZ R6,D21 ; DJNZ R5,D11 ; RET ;------------------------------------------------ DELAY2: MOV R5,#200 ;Delay process D12: MOV R6,#200 ; D22: MOV R7,#248 ; DJNZ R7,$ ; DJNZ R6,D22 ; DJNZ R5,D12 ; RET END
8051 Hardware interrupts with 7segment display 1.0
Demonstrating hardware interrupts with 7segment display.