logo

Bài giảng Kỹ thuật Vi xử lý P6


Bài gi ng K thu t Vi x lý Ngành i n t -Vi n thông i h c Bách khoa à N ng c a H Vi t Vi t, Khoa TVT Tài li u tham kh o [1] K thu t vi x lý, Văn Th Minh, NXB Giáo d c, 1997 [2] K thu t vi x lý và L p trình Assembly cho h vi x lý, Xuân Ti n, NXB Khoa h c & k thu t, 2001 Chương 6 Các ki u I/O 6.1 Thăm dò (Polling) 6.2 I/O i u khi n b ng ng t (Interrupt) - 6.3 DMA (Direct Memory Access) Thăm dò A19 5V A18 : A0 D7 A0 B0 D6 A1 B1 D5 A2 B2 D4 A3 B3 D3 A4 B4 D2 A5 74LS245 B5 8088 D1 A6 B6 Minimum D0 A7 B7 Mode E DIR IOR IOW mov dx, F000 L1: in al, dx cmp al, FF je L1 A A A A A A A A A A A A A A A A IOR : 1111119876543210 543210 : A19 5V A18 : The Circuit A0 D7 A0 B0 D6 A1 B1 D5 A2 B2 D4 A3 B3 D3 A4 B4 D2 A5 74LS245 B5 8088 D1 A6 B6 Minimum D0 A7 B7 Mode E DIR D0 Q0 D1 Q1 IOR D2 Q2 IOW D3 Q3 D4 Q4 D574LS373 Q5 D6 Q6 D7 Q7 A A A A A A A A A A A A A A A A IOR LE OE 1111119876543210 543210 AAAAAAAAAAAAAAAAIOW 1111119876543210 543210 Bài toán • Chương trình t o ra hi u ng “LED ch y”: - Ban u LED ch y t trên xu ng - Khi nh n phím th p nh t thì LED thay i hư ng ch y - Khi nh n phím cao nh t thì chương trình k t thúc Chương trình mov dx, F000 L4: mov bl, al mov ah, 00 in al, dx mov al, 01 cmp al, FF L1: out dx, al je L6 mov cx, FFFF L2: dec cx test al, 01 jnz L2 jnz L5 cmp ah, 00 xor ah, FF jne L3 jmp L6 rol al, 1 L5: test al, 80 cmp al, 01 jz L7 jne L1 L6: mov al, bl jmp L4 jmp L1 L3: ror al, 1 L7: cmp al, 80 jne L1 What’s the problem with polling in the sample program? • Running LED takes time • User might remove his/her finger from the switch • before the in al, dx instruction is executed • the microprocessor will not know that the user has pressed the button Problem with Polling mov dx, F000 L4: mov bl, al mov ah, 00 in al, dx mov al, 01 cmp al, FF L1: out dx, al je L6 mov cx, FFFF test al, 01 L2: dec cx jnz L5 jnz L2 xor ah, FF cmp ah, 00 jne L3 jmp L6 rol al, 1 L5: test al, 80 cmp al, 01 jz L7 jne L1 L6: mov al, bl jmp L4 jmp L1 L3: ror al, 1 L7: cmp al, 80 jne L1 Interrupt • The microprocessor does not check if data is available. • The peripheral will interrupt the processor when data is available Polling vs. Interrupt instruction While studying, I’ll Input Memory check the bucket every 5 Device minutes to see if it is already full so that I can transfer the content of the bucket to the drum. µP POLLING Polling vs. Interrupt instruction I’ll just study. When the Input Memory speaker starts playing Device music it means that the bucket is full. I can then transfer the content of the bucket to the drum. Interrupt request µP INTERRUPT
DMCA.com Protection Status Copyright by webtailieu.net