EE1A2 Microprocessors Revision - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

EE1A2 Microprocessors Revision

Description:

What should you be expected to do in a typical exam question ? ... 0.1s or 1/20 s. These can be achieved by simply halving or quartering MCOUNT. ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 27
Provided by: visual1
Category:

less

Transcript and Presenter's Notes

Title: EE1A2 Microprocessors Revision


1
EE1A2 MicroprocessorsRevision
  • Dr Sandra I. Woolley

2
Contents
  • Revision notes
  • Revision and exam suggestions
  • A note about writing code in the exam
  • Examples

3
EE1A2 Revision Notes
  • What should you be expected to do in a typical
    exam question ?
  • Understanding of basic principles.
  • Ability to perform simple circuit analysis and/or
    design. Write or interpret samples of code.
  • Apply skills to less familiar problems.

4
EE1A2 Part A
  • Number Systems
  • Decimal, Binary, Hex.
  • Binary Arithmetic
  • Arithmetic Logic Units
  • Addition circuits
  • Subtraction circuits
  • Flags
  • ALUs
  • Registers
  • Using a Working Register with an ALU
  • Tri-state ports Busses
  • Microcontrollers
  • Basic building blocks
  • Special purpose registers and programs

5
EE1A Part B
  • An understanding of the basic principles of
    microprocessors and appreciation of the
    difference between microprocessors,
    microcontrollers and DSPs (digital signal
    processors).
  • A working knowledge of the PIC16F84
    microcontroller.
  • Experience of assembler programming and a basic
    appreciation of embedded systems.

6
Revision Suggestions
  • Read/work through course materials and examples.
  • Look at past exam questions so that you are
    familiar with the style of questions.
  • See on-line revision materials and the University
    exam paper database http//www.exampapers.bham.ac.
    uk.
  • For this subject a keyword search may not work
    because of varied abbreviations for the long
    title. When using this database always be very
    careful that you are reading the right
    examination paper.
  • Note in previous years a different number of
    questions were required.
  • Time your attempts at questions.
  • Work out your exam technique in advance. e.g.,
    allocate a set amount of time to read through all
    questions carefully.

7
Exam Suggestions
  • Take a calculator.
  • Read questions carefully.
  • Keep a close eye on the time.
  • Keep descriptive answers short and to the point.
  • Take note of how many marks are assigned to each
    question and dont spend long on questions with
    few marks.
  • Use diagrams, tables or bullet-point lists if
    useful.

8
Writing Code in the Exam
  • We have referenced different code structures
    during the course. These include code segments,
    templates, subroutines and programs.
  • Segments are lines of code.
  • Templates are code frameworks (define the
    structure of components but dont contain any
    actual instructions)
  • Subroutines are the component program tasks
    completed by a return instruction.
  • Programs are full program listings including
    header with device and function fields.
  • You will not be asked to write a full program
    listing in the exam.
  •  

9
Writing Code in the Exam
  • Use the instruction set and/or register file map
    and information provided.
  • READ THE QUESTION VERY CAREFULLY
  • (dont write components that are NOT required)
  • You could use a simple flow diagram to get you
    started.
  • Comment your code (keep comments clear and
    concise)
  • Do you need supporting equates or org statements?
    If the question asks for them they will be worth
    marks.
  •  

10
Common Mistakes
  • that lose marks
  • Misreading the question.
  • Not using the register file list or instruction
    list.
  • Fundamental errors (e.g., errors of the type
    advantage of TMR0 delay over software delay is
    that it is faster)
  • Most common major loss of marks occurs when no
    attempt at all is made of a component.
  • that dont lose marks
  • Slightly different time delay times (our
    approximation is only an approximation - slightly
    different counter values are fine)
  • Misspelling generally loses no marks unless, for
    example, a valid instruction is misspelt as a
    different instruction
  • E.g., no lost marks for misspelling interrupt.

11
Revision Examples (A)
12
Revision Examples
  • Convert the decimal numbers 53 and 21 into binary
    (base-2) form using eight digits.
  • Calculate the twos complement representation of
    the decimal number 21.

13
Revision Examples
  • Using the circuit shown below, what is the
    relationship between the three bit output number,
    Q0-2, and the pair of inputs A0-2 and B0-2 when
  • The control input is low.
  • The control input is high.

14
Revision Examples
  • The figure below shows a positive edge triggered
    D-type flip-flop acting as a simple one bit
    information store. Copy the D and CLK signals
    and draw the missing Q signal.

Answer At first rising edge of CLK we know that
Q must be low (because D is low here) at 2nd
rising edge D is high so Q must now go high. At
last rising CLK edge D is still high so Q must
stay high I(and remain high while D goes low
because there has not been a new rising edge of
CLK.
Q
15
Revision Examples
  • In the context of a microcontroller, briefly
    describe the functions of
  • i. The Status Register.
  • ii. The Program Counter.
  • iii. The Working Register.

  • Answer
  • The status register is used to store the states
    of several flags (e.g. carry flag, zero flag)
    generated as a result of an arithmetic or logical
    operation.
  • ii. The program counter holds the address, in
    program memory, of the next instruction to be
    executed.
  • iii. The working register is used to store one of
    the operands to be inputted into the ALU and also
    stores the result of an arithmetic or logical
    operation.

16
Revision Examples
  • Briefly describe the three possible states of a
    tri-state port and their use in connecting
    devices to a common bi-directional bus.


Answer Low impedance, high (equivalent to a
ve d.c. voltage source.) Low impedance, low
(equivalent to a short circuit to ground.) High
impedance (equivalent to a large resistor
connected to ground.) In the two low impedance
states, the port can write to a common bus as
long as all other ports sharing the bus are in
the high impedance state. In the high impedance
state, a port can read from the bus or simply
ignore all bus activity.
17
Revision Examples
  • Outline the differences and the relationships
    between assembly language and machine code.


Answer A program written in assembly language is
a list of human readable code. A machine code
program, on the other hand, is a list of numbers
understood by the control unit of a
microcontroller. All assembly language
instructions map onto a unique machine code
equivalent. To convert from assembly language to
machine code, an assembler is used.
18
Revision Examples
  • The figure shows an ALU, working register and two
    general-purpose registers, R0 and R1, all
    connected to a common system bus.
  • List the data transfers required to add together
    the contents of R0 to itself and store the answer
    in register R1.
  • Answer
  • R0 outputs to the bus, W inputs and stores.
  • R0 outputs to the bus (again), the ALU adds
    (storing the result in W)
  • W outputs to the bus, R1 inputs and stores.


19
Revision Examples
  • List the data transfers required to compare for
    equality the contents of registers R0 and R1, the
    result appearing in the zero flag.
  • Answer
  • R0 outputs to the bus, W inputs and stores.
  • R1 outputs to the bus, the ALU subtracts (storing
    the difference in W)
  • The zero flag will now be high only if R0 R1


20
Revision Examples (B)
21
Revision Examples
  • Briefly describe the PIC16F84? (A descriptive
    summary of the most important points)
  • Write a simple template for a PIC assembler
    program that shows the reader the order of the
    basic contents of PIC assembler file. (For the
    program header comments, list only the important
    fields. ) (Think of the content of a typical
    program what does it contain and in what
    order?)
  • Write a simple program segment (with supporting
    equates and comments) to configure PORTA pins as
    inputs and PORTB pins as outputs.
  • What is the purpose of a data table how is it
    implemented in PIC assembler and why is it done
    this way?
  • What are the contents of the INTCON register and
    what are their function? (exact bit names and
    locations not required).
  • Briefly explain the advantages of TMRO over a
    software delay.
  • Most PIC16F84 instructions take 1 clock cycle to
    execute. Identify all the instructions which
    take always and which sometimes take longer.
    Explain why they take longer.
  • Write a 1/20 s second nested loop software time
    delay.

22
Notes on Selected Questions
  • TMR0 is the hardware timer. The software time
    delay ties up the processor. Using TMR0 means
    the processor is free to do other things. (It
    isnt faster! )
  • TMR0 overflow is one of the 4 interrupts on our
    processor.
  • The instructions all take one clock cycle except
    instructions which involve a program branch.
    Identifying these is often an exam question.
  • BTFSS and BTFSC and DECFSZ and INCFSZ all take
    one or two clock cycles.
  • BTFSS and BTFSC are useful bit test
    instructions. Test is a bit is set or clear and
    skip (the next line in the program) if the
    condition is satisfied.

23
The Basic Nested-Loop Time Delay
  • This is the 0.2s nested loop time delay from your
    lecture notes.
  • Several exam questions in the past have required
    a time delay that is a simple fraction of 0.2s
    (1/5 s), for example, 0.1s or 1/20 s. These can
    be achieved by simply halving or quartering
    MCOUNT.
  • For 0.2s delay MCOUNT255 (0xFF)
  • For 0.1s delay MCOUNT128 (0x80)
  • For 0.05s delay, MCOUNT64 (0x40)
  • etc.

DELAY MOVLW 0XFF MOVWF MCOUNT GET_N MOVLW 0
XFF MOVWF NCOUNT DEC_N DECFSZ NCOUNT,F GOTO
DEC_N DECFSZ MCOUNT,F GOTO GET_N RETURN
24
Time Delay with Flowchart
  • DELAY MOVLW 0XFF
  • MOVWF MCOUNT
  • GET_N MOVLW 0XFF
  • MOVWF NCOUNT
  • DEC_N DECFSZ NCOUNT,F
  • GOTO DEC_N
  • DECFSZ MCOUNT,F
  • GOTO GET_N
  • RETURN

25
Summary
  • Revision notes
  • Revision and exam suggestions
  • A note about writing code in the exam
  • Examples

26
Thank You and Good Luck
Write a Comment
User Comments (0)
About PowerShow.com