Tin hieu va he thong ádkjfkasjdfkasdfjk_Interrupt.pptx
LuVnVit
16 views
38 slides
Jun 21, 2024
Slide 1 of 38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
About This Presentation
dfkhgasdk skdhkaf
Size: 2.81 MB
Language: en
Added: Jun 21, 2024
Slides: 38 pages
Slide Content
THE 8051 Microcontroller: INTERRUPT & APPLICATION DESIGN MT09KTTN ĐINH HOÀNG MAI (50901524) CHIÊM THẠCH PHÁT (50901901) NGUYỄN QUỐC DUY TÂN (50902379) NGUYỄN DUY THANH (50902406) 1
CONTENTS *PART 1: INTERRUPT INTRODUCTION TO INTERRUPT TIMER INTERRUPT EXTERNAL HARDWARE INTERRUPT SERIAL COMMUNICATION INTERRUPT INTERRUPT POLLING & PRIORITY *PART 2: 89v51 & APPLICATION DESIGN 2
PART 1: INTERRUPT Objectives: In this part you will know: What is Interrupt? What is its application? How many kinds of Interrupt? How to write a program using Interrupt? 3
INTRODUCTION TO INTERRUPT What is Interrupt? An interrupt in the Microcontroller’s current work generated by an internal/external cause directs Microcontroller to other work. The Microcontroller can handle many interrupts at a time or ignore some interrupts (based on priority) MAIN MAIN ISR ISR1 ISR0 MAIN ISR0 ISR1 ISR0 MAIN TIME 4
INTRODUCTION TO INTERRUPT Interrupt Service Routine - When an interrupt is invoked, the microcontroller will run an ISR. - Interrupt service routine vs. Subroutine? * 6 ISRs (2 Timer, 2 External hardware, 1 Serial port, 1 Reset) * E ach ISR must start at a specific address 5
INTRODUCTION TO INTERRUPT Interrupt vector table 0000 0030 002F LJMP MAIN MAIN : FFFF Memory Organization when using interrupts Code area for Interrupts Code area for Main program 6
INTRODUCTION TO INTERRUPT General Structure: Small ISR (max = 8 bytes) Large ISR 7
INTRODUCTION TO INTERRUPT Enabling & Disabling Interrupt 8
INTRODUCTION TO INTERRUPT Enabling & Disabling Interrupt *Examples: 1/ The instruction to enable serial int , timer int 0 and external int 1: MOV IE,#10010110B 2/ Disabling timer int 0: CLR IE.1 3/ Disabling all interrupts: CLR IE.7 9
TIMER INTERRUPT Normal Timer vs. Timer Interrupt? Similarities : Timer 1 & 0, TMOD, THx , TLx , TFx . Differences : IE, checking/unchecking timer flag bit ( TFx ). Interrupt signal: TFx raises from 0 to 1 when time rolls over. 10
TIMER INTERRUPT Example program using Normal Timer: Generate a 50 Hz square wave on pin P1.1 (assume XTAL frequency = 12 MHz). The Microcontroller does nothing but waits Flag bit is manually cleared 11
TIMER INTERRUPT Example program using Timer Interrupt: Generate 50 Hz square wave on pin P1.1 + continuously transfer data from port 0 to port 2 The Microcontroller can do other things while waiting for interrupt signal Timer flag TF0 is automatically cleared when jumping to Timer 0 Interrupt 12
EXTERNAL INTERRUPT What is external interrupts ? 13
EXTERNAL INTERRUPT IE ( I nterrupt E nable): TCON ( T imer C ontrol): 2 activation levels: level-triggered ( IT0 = 0, IT1 = 0 ) - edge-triggered ( IT0 = 1, IT1 = 1 ) flag 14
EXTERNAL INTERRUPT L evel-triggered interrupt IT0 = 0 / TCON.0 = 0 INT0 pin high -> low - > interrupt 1 -> if INT0 pin low: interrupt 2 -> if INT0 pin low: interrupt 3 … stop interrupt when INT0 high E dge-triggered interrupt IT0 = 1 / TCON.0 = 1 INT0 pin high -> low -> interrupt -> main 15
EXTERNAL INTERRUPT ORG 0 LJMP MAIN ORG 3H CLR P3.7 RETI ORG 13H SETB P3.7 RETI ORG 30H MAIN: MOV IE, #1000 0101B SJMP $ END Example: P3.7 : turn on/off furnace INT0 = 0 if t > 25 -> turn off furnace INT1 = 0 if t < 20 -> turn on furnace 16
EXTERNAL INTERRUPT ORG 0 LJMP MAIN ORG 13H SETB P3.7 ACALL DELAY CLR P3.7 RETI ORG 30H MAIN: MOV IE,# 1000 0100B SETB TCON.2 SJMP $ END Example 2: 17
SERIAL PORT INTERRUPT 8051 18
SERIAL PORT INTERRUPT Example: ASCII ‘A’ <-> 41H <-> 0100 0001B 19
SERIAL PORT INTERRUPT IE: 1001 0000 SCON: 0101 0000 What is serial interrupts ? Jump to 0023H Execute ISR flag 20
SERIAL PORT INTERRUPT ORG 0 LJMP MAIN ORG 23H JB TI , TRANS READ: MOV A , SBUF … CLR RI RETI TRANS: MOV SBUF , A … CLR TI RETI ORG 30H MAIN : MOV TMOD , # 20H MOV TH1 , # 0FDH MOV SCON , #0101 0000B MOV IE, #1001 0000B SETB TR1 BACK: MOV A , P1 MOV SBUF , A … SJMP BACK END Example : 21
POLLING SEQUENCE If two interrupts of the same priority occur simultaneously, a fixed polling sequence determines which is serviced first. EX0 - > ET0 - > EX1 -> ET1 -> ES 22
INTERRUPT PRIORITY IP: Priority bit = 1: high priority Priority bit = 0: low priority PX0: priority external 0 PX1: priority external 1 PT0: priority timer PT1: priority timer 1 PS: priority serial 23
INTERRUPT PRIORITY 1. What happens if interrupts INT0, TF0, TF1 and INT1 are activated at the same time? -> INT0 -> TF0 -> INT1 -> TF1 2. If PX1=1 in IP register what happens if interrupts INT0, TF0, TF1 and INT1 are activated at the same time? -> INT1 -> INT0 -> TF0 -> TF1 3. If PT1=1 and PX1=1 in IP register what happens if interrupts INT0, TF0, and INT1 are activated at the same time? -> INT1 -> TF1 -> INT0 -> TF0 Example : 24
PART 2: 89v51 & APPLICATION DESIGN Objectives: In this part you will know: Some communication ports, special circuits of 8051 and their functions. Some features of 89v51. How to design many applications like LED 7-segment, LCD,… 25
Ram ADDR Register Ram Port 0 LATCH Port 2 LATCH Flash Port 1 LATCH Port 3 LATCH Port 0 DRIVERS Port 2 DRIVERS Port 1 DRIVERS Port 3 DRIVERS B REGISTER ACC TMP2 TMP1 ALU TIMING AND CONTROL INTRUCTION REGISTER OSC INTERRUPT, SERIAL PORT AND TIMER BLOCKS STACK POINTER PROGRAM ADDRESS REGISTER BUFFER PC INCREMENTER PROGRAM COUNTER DPTR PSW It’s used as a general purpose I/O port. When connecting an 8051 to an external memory, port 0 provides both address and data . It can be used for input or output, each pin must be connected externally to a 10K ohm pull-up resistor Port 2 is dual- purpose port: + purpose I/O(like port 1) + the high-byte of the address for designs with enternal code memory or more than 256 bytes of the enternal data memory Port 1 can be used as input or output port 3 is dual- purpose port: + purpose I/O(like port 1) + Port 3 has the additional function of providing some extremely important signals 26
http://www.scribd.com/doc/7023012/Gioithieu-89v51 In order for the RESET input to be effective, it must have a minimum duration of 2 machine cycles . In other words, the high pulse must be high for a minimum of 2 machine cycle before it is allowed to go low 27
89V51 80C51 Central Processing Unit 64 kB of on-chip Flash program memory Three 16-bit timers/counters Eight interrupt sources with four priority levels Second DPTR register 28
BD-9 AND RS232 An interfacing standard RS232 was set by the Electronics Industries Association (EIA) in 1960. In RS232, a 1 is represented by -3 to -25 V, while a 0 bit is +3 to +25 V, making -3 to +3 undefined 29
LED 7 đoạn APPICATION DESIGN 30
LED 7 ĐOẠN Led 7 đoạn gồm 2 loại : anode cực chung và cathode cực chung . Loại anode cực chung nối với Vcc . Loại cathode cực chung nối với đất . APPICATION DESIGN 31
Loại anode ( các led đơn sáng ở mức 0) APPICATION DESIGN 32
Loại cathode ( các led đơn sáng ở mức 1) APPICATION DESIGN 33
Điều khiển LCD với 8051 Nhiệm vụ các chân của LCD APPICATION DESIGN 34
Bảng mã LCD APPICATION DESIGN 35
LCD TIMING FOR READ APPICATION DESIGN 36
LCD TIMING FOR WRITE APPICATION DESIGN 37
REFERENCES 1. “Chapter 5: The 8051 Introduction”, lecture from Logic Design 2, DCE, HCMUT. 2. “The 8051 Microcontroller and Embedded Systems Using Assembly and C - 2 nd - ed ”, Muhammad Ali Mazidi , Janice Gillispie Mazidi , Rolin D.McKinlay . 3. “The 8051 Microcontroller - 2 nd ”, I. Scott Mackenzie, Prentice Hall 1995. 4. http:// www.scribd.com/doc/7023012/Gioithieu-89v51 5. Bkit Hardware Club: http://www.bkit4u.com 6. http://www.hoiquandtvt.net/index.php?option=com_content&view=article&id=74:giao-tip-led-7-thanh&catid=8:vdk-8051&Itemid=20 38