microprocessor and interfacing 261313

23
Microprocessor and Interfacing 261313 PIC Code Execution II http://www.e-cpe.org/moodle

Upload: howard

Post on 13-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Microprocessor and Interfacing 261313. PIC Code Execution II. http://www.e-cpe.org/moodle. Memory Mapped I/O (MMIO). MOVWF 06. W. B0 B1 B2 B3 B4 B5 B6 B7. PIC. MOVLWXX MOVWF06. PIC-C Trick: Port-level Control. #byte b_port = 6 // mem pointer - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Microprocessor and Interfacing 261313

Microprocessor and Interfacing

261313

PIC Code Execution II

http://www.e-cpe.org/moodle

Page 2: Microprocessor and Interfacing 261313

Memory Mapped I/O (MMIO)

MOVWF 06

W

Page 3: Microprocessor and Interfacing 261313

PIC

B0

B1

B2

B3

B4

B5

B6

B7

MOVLW XXMOVWF 06

Page 4: Microprocessor and Interfacing 261313

PIC-C Trick: Port-level Control

#byte b_port = 6 // mem pointer

b_port = 0xff; // drive port b

Page 5: Microprocessor and Interfacing 261313

ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O

ไม่ ต้�องออกแบบคำ��สี��งเฉพ�ะสี��หรั�บ I/O

MOVWF 06

MOVWF 21

I/O Operation

Mem Operation

Page 6: Microprocessor and Interfacing 261313

ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O

ลดีคำว�ม่ซั�บซั�อนข้อง CPU ทำ��ให�รั�คำ�ถู#กลง และ ออกแบบไดี�ง �ย

YES NO

Page 7: Microprocessor and Interfacing 261313

ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O

แต้ ก$ต้�องเสี�ยต้��แหน งใน Memory ไปบ�งสี วน

128 BytesI/O Mapped

240 BytesAvailable RAM

Page 8: Microprocessor and Interfacing 261313

3 GB?? 3 GB?? 4 GB?? 4 GB??

The 3 Gig not 4 Gig RAM Problem

32 bit

Page 9: Microprocessor and Interfacing 261313

The 3 Gig not 4 Gig RAM Problem

~1 GB

3 GB

Address Space

Video CardBIOSPCI Bus

RAM(4 GB)

Page 10: Microprocessor and Interfacing 261313

ข้�อดี�ข้�อเสี�ยข้อง Memory Mapped I/O

ถู�� Memory และ I/O ใช้� data bus เดี�ยวก�น อ�จทำ��ให� Memory Access ช้��ลง

MOVWF 06

MOVWF 21

Slow I/O Operation

FastMem Operation

Page 11: Microprocessor and Interfacing 261313

Port Mapped I/O (PMIO)

ม่� I/O Bus แยกจ�ก Memory Bus ใช้�คำ��สี��งแยกก�น

Page 12: Microprocessor and Interfacing 261313

Machine Code Generation Methods

Page 13: Microprocessor and Interfacing 261313

Options

Write Machine Code Write Assembly Code Use a High-Level Compiler

Page 14: Microprocessor and Interfacing 261313

Writing Machine CodeWriting Machine Code

ENIACENIAC

Page 15: Microprocessor and Interfacing 261313
Page 16: Microprocessor and Interfacing 261313

Drawbacks of High-Level Compilers

Poor optimization

Non-Optimal Hardware Utilization

Page 17: Microprocessor and Interfacing 261313

Poor Optimazation

.................... while (1) {

.................... output_b(i); 001A: BSF 03.5001B: CLRF 06001C: BCF 03.5001D: MOVF 21,W001E: MOVWF 06

Page 18: Microprocessor and Interfacing 261313

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

Page 19: Microprocessor and Interfacing 261313

Non-Optimal HW Utilization

Equivalent Program in ASM BCF 03.5

MOVF 0x21,W MOVWF 06 RLF 0x21, F GOTO 0x1A

RLF

Page 20: Microprocessor and Interfacing 261313
Page 21: Microprocessor and Interfacing 261313
Page 22: Microprocessor and Interfacing 261313

File Register Map

Page 23: Microprocessor and Interfacing 261313

Status Register (Address 03)