Microprocessors Typical microprocessor controlled devices Camera mobile phone

Microprocessors Typical microprocessor controlled devices: Camera, mobile phone, stereo, mp 3 player, electronic toys… High-level microprocessor controlled automation: DHL and Fed. Ex, Park and Shop, … What are the similarities ? Both types use computer control What is the difference? Real-time programmable

Basic Architecture of a microprocessor A simplified computer
![CPU: Central Processing Unit (i) Break [complex] task sequence of [very simple] sub-tasks each CPU: Central Processing Unit (i) Break [complex] task sequence of [very simple] sub-tasks each](http://slidetodoc.com/presentation_image_h2/153a2fb99bed7a0be3d66097a29df22c/image-3.jpg)
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

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 instruction decoder and
![Microprocessor memory Memory: Microprocessor memory: on chip [WHY? ] Other memory terms: - ROM Microprocessor memory Memory: Microprocessor memory: on chip [WHY? ] Other memory terms: - ROM](http://slidetodoc.com/presentation_image_h2/153a2fb99bed7a0be3d66097a29df22c/image-6.jpg)
Microprocessor memory Memory: Microprocessor memory: on chip [WHY? ] Other memory terms: - ROM - PROM (programmable ROM): - EPROM (erasable PROM: erased/reprogrammed by UV-light) - RAM

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)

Microprocessor: Machine language OPERANDS OPCODE 100011 000000 00011 00001 01000 00000100 00110 [in decimal: 35 3 [in decimal: 0 1 8 6] Line 1. Operation-code 35 (load some data into a register): Look at the number stored in register 3 Go to the memory location = [value of register 3] + 68 Get the data from that cell Store it into register 8. Line 2. Operation code 0 (add two numbers). Add the contents of register 1 and register 8 store answer into register 6. 8 68]

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] LOOP: LOOP 1: LIGHT: opcode [operands] CSEG SETB JNB AJMP Microprocessor: Assembly language [label] LOOP: LOOP 1: LIGHT: opcode [operands] CSEG SETB JNB AJMP](http://slidetodoc.com/presentation_image_h2/153a2fb99bed7a0be3d66097a29df22c/image-10.jpg)
Microprocessor: Assembly language [label] LOOP: LOOP 1: LIGHT: opcode [operands] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 [comment] ; turn off the LED ; turn on the LED

Microprocessor: Assembly language Run the program from memory location (Hexadecimal) 0000) LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assembly language 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) LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assembly language 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) LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assembly language automatic jump (unconditional jump) where? to program counter located by LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assembly language token (marks the line with a name) CLEAR: set bit = 0. which bit: port 2. 7 (pin #7 of outputs) LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assembly language automatic jump (unconditional jump) where? to program counter located by LOOP 1 LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] ; turn off the LED ; turn on the LED [comment]
![Microprocessor: Assembly language terminate program (erase it from RAM) LOOP: LOOP 1: LIGHT: [label] Microprocessor: Assembly language terminate program (erase it from RAM) LOOP: LOOP 1: LIGHT: [label]](http://slidetodoc.com/presentation_image_h2/153a2fb99bed7a0be3d66097a29df22c/image-17.jpg)
Microprocessor: Assembly language terminate program (erase it from RAM) LOOP: LOOP 1: LIGHT: [label] CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 opcode [operands] Question: When will it END ? ; turn off the LED ; turn on the LED [comment]

Microprocessor: Assemblers Assembly programming software What’s happening here ?

Burning a PROM

Hardwired Microprocessor control LOOP: LOOP 1: LIGHT: CSEG SETB JNB AJMP CLR AJMP END AT 0000 H P 2. 7 P 0. 7, LIGHT LOOP P 2. 7 LOOP 1 ; turn off the LED ; turn on the LED

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 System Examples: What does it do ? Compiler(s) Examples: What do they do ? Application programs Examples: What do they do?
- Slides: 23