Microprocessor and Interfacing 261313
description
Transcript of Microprocessor and Interfacing 261313
Microprocessor and Interfacing
261313
PIC Code Execution II
http://www.e-cpe.org/moodle
Memory Mapped I/O (MMIO)
MOVWF 06
W
PIC
B0
B1
B2
B3
B4
B5
B6
B7
MOVLW XXMOVWF 06
PIC-C Trick: Port-level Control
#byte b_port = 6 // mem pointer
b_port = 0xff; // drive port b
ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O
ไม่ ต้�องออกแบบคำ��สี��งเฉพ�ะสี��หรั�บ I/O
MOVWF 06
MOVWF 21
I/O Operation
Mem Operation
ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O
ลดีคำว�ม่ซั�บซั�อนข้อง CPU ทำ��ให�รั�คำ�ถู#กลง และ ออกแบบไดี�ง �ย
YES NO
ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O
แต้ ก$ต้�องเสี�ยต้��แหน งใน Memory ไปบ�งสี วน
128 BytesI/O Mapped
240 BytesAvailable RAM
3 GB?? 3 GB?? 4 GB?? 4 GB??
The 3 Gig not 4 Gig RAM Problem
32 bit
The 3 Gig not 4 Gig RAM Problem
~1 GB
3 GB
Address Space
Video CardBIOSPCI Bus
RAM(4 GB)
ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O
ถู�� Memory และ I/O ใช้� data bus เดี�ยวก�น อ�จทำ��ให� Memory Access ช้��ลง
MOVWF 06
MOVWF 21
Slow I/O Operation
FastMem Operation
Port Mapped I/O (PMIO)
ม่� I/O Bus แยกจ�ก Memory Bus ใช้�คำ��สี��งแยกก�น
Machine Code Generation Methods
Options
Write Machine Code Write Assembly Code Use a High-Level Compiler
Writing Machine CodeWriting Machine Code
ENIACENIAC
Drawbacks of High-Level Compilers
Poor optimization
Non-Optimal Hardware Utilization
Poor Optimazation
.................... while (1) {
.................... output_b(i); 001A: BSF 03.5001B: CLRF 06001C: BCF 03.5001D: MOVF 21,W001E: MOVWF 06
Poor Optimization Ex 2.................... int i; .................... i = 5; 000D: MOVLW 05000E: BCF 03.5000F: MOVWF 21.................... do { .................... i--; 0010: DECF 21,F.................... } while (i>0); 0011: MOVF 21,F0012: BTFSS 03.2 0013: GOTO 010
Non-Optimal HW Utilization
Equivalent Program in ASM BCF 03.5
MOVF 0x21,W MOVWF 06 RLF 0x21, F GOTO 0x1A
RLF
File Register Map
Status Register (Address 03)