Assignment1 Solution
Assignment1 Solution
Instructions:
Questions
ROM
CPU
Addres s Bus
Data Bus
General-
Purpose
I/O Serial
Microprocessor RAM Timer
Port Port
Addres s Bus
ROM
CPU
Addres s Bus
Data Bus
General-
Purpose
I/O Serial
Microprocess or RAM Timer
Port Port
Addres s Bus
Page 1 of 5
FA21-EEE-5 Assignment# 1 Solution
Microprocessor and System Interfacing
A microprocessor based system requires more time to setup, is costly due to required
external components. External components are connected using wires (busses) to the
microprocessor. However, microprocessors offers flexibility and one can use a program
memory and ram according to requirements.
Von Neumann architecture has single bus for accessing data and instructions while Harvard
architecture has separate busses for accessing data and instructions. Harvard architecture
offers superior performance (allows simultaneous access to instructions and data) at the
cost of extra wires, cost is significant if the memories are connected externally to chip.
Harvard architecture is more suitable for microcontrollers where both the memories and
busses are on-chip, this does not significantly increase cost, as there is no increase in
external wires.
2. Discuss the components inside a CPU, along with the functions they perform to make a
CPU? What is the role of Program and Data memory?
The major components of the CPU are:
I. Program counter (contains address of the instruction to be executed next)
II. Instruction register (contains the read instruction from Program memory)
III. Instruction Decoder
a. Translate fetched instruction
b. CPU Control signals
i. Like enable ALU or write register
IV. ALU (Arithmetic and Logic unit)
a. Name well explained
b. ALU performs a specific arithmetic of logic function (depends on control
signals)
V. Status Register, has flags which store additional information about the result of ALU
a. Whether the result is zero, or negative or carry (overflow) etc.
VI. Registers, contains data on which CPU performs operations
a. Registers are highest (fastest) data memory
Program memory contains instructions, which guide CPU in performing a task. Data memory is
the workspace where the CPU performs operations. Data memory includes CPU internal
Registers, RAM and Special functions registers. Special function registers allows CPU to access
other peripherals.
Page 2 of 5
FA21-EEE-5 Assignment# 1 Solution
Microprocessor and System Interfacing
CPU
Registers
Program
Memory
(ROM)
ALU Other
RAM
data bus Instruction Peripherals
Decoder
Status
address bus Program Register
PROGRAM Bus Counter
DATA Bus
3. Discuss the various aspects of comparison when choosing a microcontroller for a particular
application.
When choosing a microcontroller, following a considered
a. Meeting computing needs and cost
i. Speed, packaging, power consumption, RAM, ROM & I/Os etc.
ii. cost per unit
b. Availability of software and hardware tools
i. An efficient C compiler, even cost of the compiler
ii. Third party solutions available like WinAVR, Kiel, COSMIC
c. Wide availability of microcontroller from various sources
i. Ready availability for various suppliers
ii. Future availability
4. Draw waveforms for accessing a memory showing all interfaces
a. Reading location 0x39 which has data 0x49.
CS
OE
WE
Address 0x39
OE
WE
Address 0x20
Page 3 of 5
FA21-EEE-5 Assignment# 1 Solution
Microprocessor and System Interfacing
5. Write an Assembly program that writes 0b00000011 to PortC and increments PortC 2×NNN
times. NNN is the last three digits of your registration number.
let NNN =100
6. Write an Assembly program that makes a running LEDs program controlled by two
switches. SW1 switches to previous state, SW2 switches to next state. When SW1
is pressed PB.0 goes zero, when SW2 is pressed SW2 is press PB.1 goes zero. Also
draw schematic.
SW1
State PortD 1 8
SW1
SW1
1. SW2
2. SW2 SW2
3. 2 7
SW1
U1
9 22
RESET PC0/SCL
23
PC1/SDA
13 24
XTAL1 PC2/TCK
12 25
XTAL2 PC3/TMS
26
PC4/TDO
40 27
PA0/ADC0 PC5/TDI
39 28
PA1/ADC1 PC6/TOSC1
38 29
PA2/ADC2 PC7/TOSC2 RN1 U2
37
PA3/ADC3
R2 R1 36
PA4/ADC4 PD0/RXD
14 1 16 1 20
35 15 2 15 2 19
SW1 10k 10k
34
PA5/ADC5 PD1/TXD
16 3 14 3 18
PA6/ADC6 PD2/INT0
33 17 4 13 4 17
PA7/ADC7 PD3/INT1
Previous 18 5 12 5 16
PD4/OC1B
1 19 6 11 6 15
PB0/T0/XCK PD5/OC1A
2 20 7 10 7 14
SW2 3
PB1/T1 PD6/ICP1
21 8 9 8 13
PB2/AIN0/INT2 PD7/OC2
4 9 12
PB3/AIN1/OC0
Next 5 220 10 11
PB4/SS
6
PB5/MOSI
7 32 LED-BARGRAPH-GRN
PB6/MISO AREF
8 30
PB7/SCK AVCC
ATMEGA16
Page 4 of 5
FA21-EEE-5 Assignment# 1 Solution
Microprocessor and System Interfacing
Page 5 of 5