An Example Of Interrupt Programming

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View An Example Of Interrupt Programming as PDF for free.

More details

  • Words: 487
  • Pages: 3
An Example of Interrupt Programming Description: In this example, I programmed the 89S52 to work with INT1 interrupt. It move to port 0 numbers from 0 to 100 respectively and repeatedly If Pin 13( INT1) is set to 0, it do the interrupt: Read from Port1 and move to Port0 But as INT1 is back to High, it returns to counting routine, countinue from the value before interrupt This is the circuit for the example:

U1 19 18

9

R3 1R

XTAL1 XTAL2

RST

R2 1R

29 30 31

1 2 3 4 5 6 7 8

PSEN ALE EA

P1.0/T2 P1.1/T2EX P1.2 P1.3 P1.4 P1.5 P1.6 P1.7

P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD

39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17

U2

R1 1R

7 1 2 6 4 5 3

A B C D BI/RBO RBI LT

QA QB QC QD QE QF QG

13 12 11 10 9 15 14

74LS47

AT89C52

Circuit for 89S52 working with INT1 Interrupt

This is the code in ASM ; This program is written for 89S52 to do these works: ; It Drive a 74LS47 to count from 0 to 9 repeatedly, 7447 is connected to 4 low significant pins of Port 0

; But when Pin INT1 is set, It Pause counting and read from Port 1 then display the value to port 0 ; Use interrupt

ORG 000H LJMP Main

; Jump to Main

ORG 0013H Push P0 Mov A, P1 Mov P0, A Mov R3, #200 Back: Djnz R3,Back

; Interrupt ; Push value of P0 to stack

; Wait

Pop P0 RETI

; Get P0 from the stack ; Return from interrupt

;-----------Main-----------ORG 30H Main: Mov IE, #10000100B

; INT1 interrupt enable

Start: Mov

P0, #0

; all the out put at Pin 0s are

low LCall Delay ; Call function for 1s delay Mov P0, #1 ; Output is 1 LCall Delay Mov P0, #2 ; Output is 2 LCall Delay Mov P0, #3 ; Output is 3 LCall Delay Mov P0, #4 ; Output is 4 LCall Delay Mov P0, #5 ; Output is 5 LCall Delay Mov P0, #6 ; Output is 6

Lcall Delay Mov P0, #7 LCall Delay Mov P0, #8 LCall Delay Mov P0, #9 LCall Delay Sjmp Start

; Output is 7 ; Output is 8 ; Output is 9 ; Back to start

; Function Delay Delay: Mov R7,#0FFH ;R7= FF Loop2: Mov R6,#0FFH ;R6= FF Loop1: Djnz R6,Loop1 ;Decrease R6 for R6 greater than zero then jump to Loop1 Djnz R7,Loop2 ;Decrease R7 for R7 greater than zero then jump to Loop2 Ret ;End the function Delay and return memory End ;End program

This circuit and code work well in my

Related Documents

Programming Example
May 2020 10
Interrupt
July 2020 7
Interrupt
November 2019 15