microprocessors typical microprocessor controlled devices: camera, mobile phone, stereo, mp3 player,...

23
Microprocessors pical microprocessor controlled devices: Camera, mobile phone, stereo, mp3 player, electronic toys igh-level microprocessor controlled automation: DHL and FedEx, Park and Shop, … What are the similarities ? Both types use computer control What is the difference? Real-time programmable

Upload: davin-hogwood

Post on 14-Dec-2015

249 views

Category:

Documents


0 download

TRANSCRIPT

Microprocessors

Typical microprocessor controlled devices:

Camera, mobile phone, stereo, mp3 player, electronic toys…

High-level microprocessor controlled automation:

DHL and FedEx, Park and Shop, …

What are the similarities ?Both types use computer control

What is the difference?Real-time programmable

Basic Architecture of a microprocessorA simplified computer

Address Bus (16 lines for 8-bit CPU)

Input/Output CPU Memory

Data bus (8 lines for 8-bit CPU)

Control Bus (10 lines)

CPU: Central Processing Unit

(i) Break [complex] task sequence of [very simple] sub-tasks

each sub-task: dedicated circuit inside the CPU

(ii) Perform each sub-task sequentially, in T units of time (or less)

until all sub-tasks have been done

Instruction Register

Work registers (including Accumulator)

Control Unit ALU

Program CounterStatus Register

Clock

Control Bus Data Bus

D7 - D0 A15 - A0

Address Bus

CPU structure

The Accumulator: main register of the ALU

Each ALU operation:operand (data value) accumulator operand memory

output accumulator.

The instruction register holds the binary code of the instruction that is being executed.

The program counter contains the address of the memory location from which the next instruction code will be taken.

Microprocessors: Control unit

The control unit controller-sequencer and

instruction decoder

Instruction Register

Work registers (including Accumulator)

Control Unit ALU

Program CounterStatus Register

Clock

Control Bus Data Bus

D7 - D0 A15 - A0

Address Bus

Microprocessor memory

Memory:

Microprocessor memory: on chip [WHY?]

Other memory terms:- ROM- PROM (programmable ROM):- EPROM (erasable PROM: erased/reprogrammed by UV-light)- RAM

A11

A12

A15A10-A0A10-A0

D7-D0

Address bus

Data bus

A15 - A0

C P U

D7 - D0

R/W

RAM2048 x 8

R/W

CS

ROM2048 x 8

CS2 - 4

decoder

G

CS2

CS3

CS4

CS1

D7-D0

Microprocessor: Input and Output

I/O chips are connect the microprocessor to a variety of devices.

EXAMPLES:memory disks, printers, data-links to other computers,instrumentation controlling equipment, etc.

Common of I/O chips:

Parallel Input/Output (PIO)

Serial I/O (UART, Universal Asynchronous Receiver/Transmitter)

To CPU To External Devices

Chip selectRead/Write

A0A1

Address Lines

D0D1D2D3D4D5D6D7

Data Lines

CSR/W

UART

Clock

Transmit

Receive

RTS (Request to Send)

CTS (Clear to Send)

DTR (Data Terminal Ready)

DSR (Data Set Ready)

Ground

RS 232 - C pin no.

2

3

4

5

20

6

7

To CPU To External Devices

Port A

Port B

Port C

Chip select

Read/Write

A0A1

Address Lines

D0D1D2D3D4D5D6D7

Data LinesPIO

CS

R/W

Microprocessor: Machine language

100011 00011 01000 0000000001000100 [in decimal: 35 3 8 68]000000 00001 01000 00110 [in decimal: 0 1 8 6]

OPCODE OPERANDS

Line 1.Operation-code 35 (load some data into a register):

Look at the number stored in register 3Go to the memory location = [value of register 3] + 68Get the data from that cellStore it into register 8.

Line 2.Operation code 0 (add two numbers).

Add the contents of register 1 and register 8store answer into register 6.

Microprocessor: Assembly language

Machine language:Difficult to write programs!

Assembly language:English codes for each opcode and operand

Easier to program

Need a way to convert Assembly language machine language

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

Run the program from memory location (Hexadecimal) 0000)

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

token (marks the line with a name)

set bit: set the value of a bit = 1

which bit: port 2.7 (pin #7 of outputs)

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7, LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

token (marks the line with a name)

JUMP if NOT: if the bit is not set, i.e. = 0.

which bit: port 0.7 (pin #7 of inputs)

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

automatic jump (unconditional jump)

where? to program counter located by LOOP

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7, LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

token (marks the line with a name)

CLEAR: set bit = 0.

which bit: port 2.7 (pin #7 of outputs)

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

automatic jump (unconditional jump)

where? to program counter located by LOOP1

Microprocessor: Assembly language

[label] opcode [operands] [comment]

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7, LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

terminate program (erase it from RAM)

Question: When will it END ?

Microprocessor: Assemblers

Assemblyprogrammingsoftware

What’shappening

here ?

Burning a PROM

power supply input port, P0.7

output port, P2.7Processor with program in PROM

power supply input port, P0.7

output port, P2.7Processor with program in PROM

Hardwired Microprocessor control

CSEG AT 0000HLOOP: SETB P2.7 ; turn off the LEDLOOP1: JNB P0.7,LIGHT

AJMP LOOPLIGHT: CLR P2.7 ; turn on the LED

AJMP LOOP1END

How about Computer control ?

Need a special board that can communicate with processor

plug it here

Need a program that can communicate with the board: (device driver)

Connect output sockets on this board to outside actuators/sensors

How about Computer control ??

Need a program that can communicate with the board: (device driver)

How to use the device driver ?

If device driver is written in C++:

Write your program in C++Link your program to device driver (library)Your program device driver

Computer basics

Operating SystemExamples:

What does it do ?

Compiler(s)Examples:

What do they do ?

Application programsExamples:

What do they do?