1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

8051 Hardware interrupts with 7segment display 1.0

Demonstrating hardware interrupts with 7segment display.

  1. sajiv jess
    Demonstrating hardware interrupts with 7segment display.
    Download contains the source code with proteus simulation file.

    Sponsored Links

    Circuit Diagram
    [​IMG]
    Assembly Code
    Code (Text):
    1. ORG    00H
    2.     JMP    MAIN
    3.     ORG    03H        ;INT0 interrupt subroutine starting address
    4.     JMP    EXT0        ;Interrupt subroutine
    5.     ORG    13H        ;INT1 interrupt subroutine starting address
    6.     JMP    EXT1        ;Interrupt subroutine
    7.     ORG    30H
    8. MAIN:    MOV    IE,#10000101B    ;INT0,INT1 Interrupt Enable
    9.     MOV    IP,#00000010B    ;INT1 Interrupt Priority
    10.     MOV    TCON,#00000001B    ;INTO is falling edge trigger
    11.     MOV    SP,#70H        ;Set stack pointer
    12.     MOV    R2,#00        ;Count initial value setting
    13.     CLR    P1.7        ;
    14. ;--------------------------------------------------
    15. LOOP:    MOV    A,R2        ;Remember to read decimal values
    16.     MOV    P2,A        ;Show
    17.     JMP    LOOP        ;Cycle
    18. EXT0:    PUSH    ACC        ;The stack
    19.     PUSH    PSW        ;
    20.     MOV    A,R2        ;
    21.     ADD    A,#01H        ;Count pointer plus 1
    22.     DA    A        ;Do decimal adjustment
    23.     MOV    R2,A        ;Into R2
    24.     MOV    P2,A        ;
    25. ;    CALL    DELAY1        ;Delay
    26.     POP    PSW        ;The stack
    27.     POP    ACC        ;
    28.     RETI            ;Interrupt return
    29. ;-----------------------------------------------
    30. EXT1:    PUSH    ACC        ;The stack
    31.     PUSH    PSW        ;
    32.     SETB    P1.7        ;
    33.     CALL    DELAY2        ;Delay
    34.     CLR    P1.7        ;
    35.     POP    PSW        ;The stack
    36.     POP    ACC        ;
    37.     RETI            ;Interrupt return
    38.  
    39. ;-----------------------------------------------
    40. DELAY1:    MOV    R5,#200        ;Delay process
    41. D11:    MOV    R6,#100        ;
    42. D21:    MOV    R7,#248        ;
    43.     DJNZ    R7,$        ;
    44.     DJNZ    R6,D21        ;
    45.     DJNZ    R5,D11        ;
    46.     RET
    47. ;------------------------------------------------
    48. DELAY2:    MOV    R5,#200        ;Delay process
    49. D12:    MOV    R6,#200        ;
    50. D22:    MOV    R7,#248        ;
    51.     DJNZ    R7,$        ;
    52.     DJNZ    R6,D22        ;
    53.     DJNZ    R5,D12        ;
    54.     RET
    55.     END    
Loading...