Sie sind auf Seite 1von 4

Name:

Dr JBO

Student ID Number: U10217


Section: 01A / 01B / EEEB374 Section 01
Lecturer: Dr. Jamaludin Bin Omar

College of Engineering

Department of Electronics and Communication Engineering

Test 1 Question Set 2 MODEL ANSWER


SEMESTER 1, ACADEMIC YEAR 2008/2009

Subject Code
Course Title
Date
Time Allowed

:
:
:
:

EEEB373/4
Microprocessor Systems
31st July 2007
50 minutes

Instructions to the candidates:


1. Write your Name and Student ID number. Circle your section number.
2. Write all your answers using pen. DO NOT USE PENCIL except for the diagram.
3. This test is closed book and closed note. Clean PIC18 Instruction Set and calculator are
allowed during the test.
4. ANSWER ALL QUESTIONS ON THIS TEST PAPER.
5. WRITE YOUR ANSWER ON THIS TEST PAPER.

NOTE: DO NOT OPEN THE QUESTION PAPER UNTIL INSTRUCTED TO DO SO.

GOOD LUCK!

1. Show your detailed work to calculate 2879

+ 0x8A6 87112. Find the result in:


1218

a) Decimal

Answer:

[4 marks]

b) Binary Coded Decimal (BCD)

Answer: 0001 0010 0001 1000

c) Binary

Answer:

10011000010

[4 marks]

d) Octal

Answer:

2302

[2 marks]

e) Hexadecimal

Answer:

4C2

[2 marks]

[2 marks]

Show your detailed work here! You will get full marks when detailed works are shown.

2879 = 2 x 92 + 8 x 9 + 7 = 162 + 72 + 7 = 241


0x8A6 = 8 x 162 + 10 x 16 + 6 = 2048 + 160 + 6 = 2214
87112 = 8 x 122 + 7 x 12 + 1 = 1152 + 84 + 1 = 1237
2879 + 0x8A6 87112 = 241 + 2214 - 1237 = 1218
Decimal

Decimal 1218

[1]
[1]
[1]
[1/2]
[1/2]

BCD

Change each decimal 1218 digit to 4-bit = 0001 0010 0001 1000

Binary

Decimal 1218 divide by 2 and collect the remainder = 10011000010 [1/2]

1218/2 = 609
609/2 = 304
304/2 = 152
152/2 = 76
76/2 = 38
38/2 = 19
19/2 = 9
9/2 = 4
4/2 = 2
2/2 = 1
1/2 = 0

Remainder 0
Remainder 1
Remainder 0
Remainder 0
Remainder 0
Remainder 0
Remainder 1
Remainder 1
Remainder 0
Remainder 0
Remainder 1

[2 marks]

Collect the remainders from bottom to top


= 10011000010
[3.5 marks]

Octal
or

Group Binary number in 3 bits [10011000010] [1.5 marks] = 2302 [1/2]


Decimal 1218 divide by 8 and collect the remainder [1.5 marks]

Hex
or

Group Binary number in 4 bits [10011000010] [1.5 marks] = 4C2 [1/2]


Decimal 1218 divide by 16 and collect the remainder [1.5 marks]

2. What are 3 similarities between EPROM and EEPROM?


Answer:

[6 marks]

Read-only memories
Programmable memory programmed by user
Erasable memory
Data stored in memory are non-volatile
[2 marks for each answer, maximum of 6 marks]

3. Describe how communication between PIC18 CPU to its program memory and data memory
are different.
[6 marks]
Answer:
PIC18 CPU communicates with its program memory using 16-bit instruction bus,
while it communicates with its data memory using 8-bit data bus. Each program
memory location is addressed using 21-bit program address, while each data memory
location is addressed using 12-bit register address. [Refer to Figure 1.3 in the note!]
[6 marks]

4. What is the purpose of access bank and bank select register (BSR) in the PIC18 CPU? Show
your calculation to determine how many banks required for a PIC18 device with 1536 bytes of
data memory.
[6 marks]
Answer:
Access bank is created to minimize the problems of bank switching when data memory
required for an operation is within the range of the access bank, which consists of the lowest
96 bytes in general-purpose registers (0x000 to 0x05F) and the highest 160 bytes of special
function registers (0xF60 to 0xFFF).
[2 marks]
Bank select register (BSR) is used to keep or store highest 4 bits of address lines of the
data memory required for an operation. This will pinpoint the exact register in a particular
bank of data memory to be operated on when the required bank is selected to be active.
[2 marks]
For 1536 bytes of data memory:
Number of memory banks required = 1536 / 256 = 6 banks.
[2 marks]

5. Write the PIC18 instruction sequence to perform the tasks.


(a) A data register is at address 0x068. You want to subtract from its contents a value of 0x24.
[4 marks]
Answer:
Since 0x068 is not in the Access Bank, need to use BSR to access the address!
0
;Bank 0
movlb
[1/2]
[1/4]
movlw
[1/2]

0x24
[1/4]

;Value to be subtracted = 0x24

subwf
[1]

0x68,F,BANKED
[1/2] [1/2] [1/2]

;Do the task required

(b) A data register is at address 0x639. You want to add its contents with the content of WREG
and the result will be saved in the data register.
[4 marks]
Answer:
Since 0x639 is not in the Access Bank, need to use BSR to access the address!
movlb
6
;Bank 6
[1]
[1/2]
addwf
[1]

0x39,F,BANKED
[1/2] [1/2] [1/2]

;Do the task required

6. Use the PIC18 instruction set to produce machine codes (in hexadecimal) for the following
PIC18 instructions.
Machine code

lfsr

FSR2,0x786

addwf

0x32,F,A

movlw

O57

subwf

D89,F,A

1110 1110 0010 0111


1111 0000 1000 0110
EE 27 F0 86
[1] [1] [1] [1]
0010 0110 0011 0010
26 32
[1] [1]
0000 1110 0010 1111
0E 2F
[1] [1]
0101 1110 0101 1001
5E 59
[1] [1]

[Binary, get 1 mark]


[Binary, get 1 mark]
[4 marks]
[Binary, get 1 mark]
[2 marks]
[Binary, get 1 mark]
[2 marks]
[Binary, get 1 mark]
[2 marks]

Note: Answer in binary number will give half of total mark for the question. Answer in hex gets the full marks.

Das könnte Ihnen auch gefallen