Sie sind auf Seite 1von 7

Aeronautical Telecommunication Engineering School CANDIDATE ASSESSMENT

PROGRAMME: Post Graduate Diploma in Air Traffic Safety PProg No: PGDATSEE1 Electronics Engineering. Module Name: Microprocessor & Embedded System. Module No: ATE 613 Coursework 2: - (weighting: %) Assessment Title 1. A) Write the 8086 Microprocessor instructions to carry out the following operations: I. Complement the contents of the carry flag. II. Rotate the contents of the accumulator by one bit to the left through carry. B) State the function of each of the following instructions: I. JNZ DELAY II. CPL A, R2 C) State the difference between CMP and SUB instructions D) The 8051 controller displays five advert pictures on an LCD display. Each picture is displayed for a period of five seconds (delay) after which the next picture will be displayed for another five seconds. Assume that the controller executes five instructions in one microsecond. Using general purpose registers, write the nested-loop code to implement delay. 2. Interface external program memory with 8051 and briefly explain how data is transferred. 3. Using 7-segment display modules, design an 8051 microcontrollerbased display board to display HELLO. Write the program code that will enable the smooth display of the characters.
Students Name Assessors Name Date Set: Date Received: OYELOWO Samuel

Engr. Isa Danjuma.


Submission Date: Referral Date:

April 29, 2013

May 21, 2013

Feedback Date:

ASSESSORS GENERAL COMMENTS: Signature: GRADE/MARK: INTERNAL VERIFIER SAMPLED BY IV DATE DATE Date:

Issue 1 11/01/13

ASSESSMENT ` FEEDBACK FORM


Assessment Criteria Achieved Yes/No Evidence Comments/Feedback

Yes/No

Yes/No

Yes/No

Yes/No

Declarations: I am aware of the Ethical and the Health & Safety issues concerned with the satisfactory completion of this coursework; and I have taken all relevant measures accordingly. I hereby certify that this submission is entirely mine and that the Institution can penalise me under the Plagiarism rule if found otherwise.

Signature:

Oyelowo .S

Date:

21th May 2013.

Issue 1 11/01/13

COURSEWORK 2 ON MICROPROCESSORS & EMBEDDED SYSTEMS

Submitted by

SAMUEL OYELOWO PG/2013/0014

PGD AIR TRAFFIC SAFETY ELECTRONICS ENGINEERING (ATE SCHOOL)

COURSE INSTRUCTOR: ENGR. ISA DANJUMA

DATE: 21/05/2013.

Question 1:
3
Issue 1 11/01/13

A. Write the 8086 Microprocessor instructions to carry out the following operations: I. Complement the contents of the carry flag. II. Rotate the contents of the accumulator by one bit to the left through carry. B. State the function of each of the following instructions: i. JNZ DELAY ii. CPL A, R2 C. State the difference between CMP and SUB instructions. D. The 8051 controller displays five advert pictures on an LCD display. Each picture is displayed for a period of five seconds (delay) after which the next picture will be displayed for another five seconds. Assume that the controller executes every instruction in 1 microsecond. Using the general purpose registers, write the nested-loop code to implement delay. Solution 1: A. I. MOV AL, 72H MOV BL, 41H ADD AL, BL CMC AL II. STC MOV AL, 1CH RCL AL, 1

; AL = 72H = 0111 0010 ; BL = 41H = 0100 0001 ; AL = AL + BL = 1011 0011; Carry Flag CF = Set ; AL = 0011 0011; CF = Reset. ; Set Carry (CF = 1) ; AL = 0001 1100 ; AL = 0011 1001

B. i. ii. JNZ DELAY: This is a conditional jump instruction used when some conditions are in act. Used to transfer control to another point in a program for a short duration. CPL A, R2: This instruction complements the contents of register R2 to that of the accumulator.

C. Difference between CMP and SUB instructions: They both subtract and set flags but CMP does not store result while SUB does. D. Parameters Given: Instruction execution time of microcontroller = 1s (microseconds) Each picture is displayed for 5-sec If in 10-6sec All instruction is been executed Then, in 1sec 1,000,000 instructions will be executed Therefore, for a display of 5sec 5,000,000 instructions will be executed. Since, maximum mask in a given byte = 255 Therefore, for the microcontroller to execute 5,000,000 instructions, it will require up to 3general purpose registers. i.e. Register R1; A = 200 instructions Register R2; B = 200 instructions
4
Issue 1 11/01/13

Register R3; C = 125 instructions Such that, A*B*C = 200*200*125 = 5,000,000 instructions Nested-loop code given below: L3: L2: L1: MOV R1, A MOV R2, B MOV R3, C DEC R3 JNZ L1 DEC R2 JNZ L2 DEC R1 JNZ L3 NOP END

Solution 2: External Program Memory (ROM-Read only Memory) interface with 8051 Microcontroller
P1 EA 8051 ALE P0 D0-D7

LATCH
(Clk)

ROM A0-A7 Address

P3 PSEN

P2

A8-A15 OE

In the diagram above, Port 0 and Port 2 provide 16-bit address to access external memory. P0 provides the lower 8 bit address A0 A7, and P2 provides the upper 8 bit address A8 A15. P0 is also used to provide the 8-bit data bus D0 D7. P0.0 P0.7 are used for both the address and data paths (address/data multiplexing).

ALE (address latch enable) pin is an output pin for 8051. When ALE = 0, P0 is used for data path and when ALE = 1, P0 is used for address path. To extract address from P0 pins, P0 is connected to an external latch and ALE signal is generated by 8051 which is then used to latch the address. Normally when ALE = 0, P0 is used as a data bus, sending data out or bringing data in. However, whenever the
5
Issue 1 11/01/13

8051 wants to use P0 as an address bus, it will put the addresses A0 A7 on the P0 pins and activates ALE = 1. PSEN (Program Store Enable) signal is an output signal for the 8051 microcontroller and must be connected to the OE (Output Enable) pin of a ROM containing the program code. Whenever the EA pin is connected to GND (Ground), the 8051 fetches Opcode from external ROM using the PSEN.

Solution 3:

5v

P2

8051 H P1 E L L O

Note: Each connection to P1 has to be connected to a limiting resistor. P1 = Display Symbol Each connection to P2 will also be connected to a limiting resistor. P2 = Display Select. Analysis for P1: Symbol a b c H E L L O 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 Mask d e f 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Hex g 0 0 1 1 1 d p 1 1 1 1 1 91h 61h E3h E3h 03h

Issue 1 11/01/13

Analysis for P2: 7 0 0 0 0 0 0 6 0 0 0 0 0 0 5 0 0 0 0 0 0 4 0 1 0 0 0 0 3 0 0 1 0 0 0 2 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 Hex 16h 08h 04h 02h 01h

Program code to display characters: AGAIN: IN P1, 00H ; this programs Port P1 as output port making all bits in the input = 0 IN P2, 00H ; this also programs Port P2 as output making all bits in input = 0. OUT P1, 91H OUT P2, 16H SJMP Delay OUT P1, 61H OUT P2, 08H SJMP Delay OUT P1, E3H OUT P2, 04H SJMP Delay OUT P1, E3H OUT P2, 02H SJMP Delay OUT P1, 03H OUT P2, 01H SJMP Delay JMP AGAIN

Reference(s) Ayala, J.K., (1991), The 8051 microcontroller architecture, programming and applications. Engr. Danjuma, I., (2013), Lecture note on microprocessors and embedded systems. Mazidi, M.A. and Mazidi, J.G., (2009), The 8051 microcontroller and embedded systems. Department of computer science and information engineering, national cheng kung university, Taiwan. Krishna, R. and Vishnu, V.N., (n.d), 8086 microprocessor instruction set. Sedory, D.B., (n.d), Documentation for emu8086-assembler and microprocessor emulator.

Issue 1 11/01/13