Professional Documents
Culture Documents
ECX4236
Day School 01
(06th March 2016)
N. I Vithanage
• Demonstrator
• Lab instructors
2
Course Introduction
3
Assessments
• Final Examination
– No Book type
– Not allowed any reference materials
– 3 hour
4
Eligibility Criteria
5
Lab Practical Sessions
7
Moodle Virtual Class
8
Why this Course is important?
9
Course Structure
Microprocessors and Interfacing
Microprocessor Interfacing
- Input
(Switches, Sensors, etc)
- Output
Hardware Assembly (LEDs, Motors/Drivers, etc.)
Architecture Programming
- Memory - Coding
- Registers - Compiling
- I/O - Simulating/ Debugging
- Timers/ Counters - Running on 8051
10
Background Knowledge Needed
• Computer Hardware level operation
– Basic knowledge of computer hardware
– Number Systems
– Read/ Write Operation
– Addressing Modes
– Operations of the Fetch - Execute cycle
Reference: ECX3233- Unit1- Hardware
• Other
– Basic electronics knowledge
– Basic knowledge about Sensors, Transducers and Actuators
11
Microprocessor Vs Microcontroller
Microprocessor Microcontroller
Generally does not have A microcontroller is all in one
RAM, ROM (processor, RAM, IO all on the
one chip)
It is capable of being built Usually used for more
into bigger general purpose dedicated applications.
applications.
Size of ROM, RAM, I/O ports Fixed amount of RAM, ROM,
can be changed I/O Ports.
Expensive Low cost
12
Hardware Architecture
13
Memory Architecture
Internal Memory
14
On-Chip Memory
Register Banks
Bit Memory
16
Pin Description (8051)
• 40 Pins
• 32 Pins are used for I/O
• 24 Pins are Duel purpose
(operates as I/O or control line
or part o addresses or data bus)
• Analog to Digital (ADC)
Input
• External Interrupts
17
IO Ports/ Pins
pin
Microcontroller
Development Board
18
Timers/ Counters - SFR
Timer SFRs
19
Timers/ Counters - Modes
Timer Modes
20
Assembly Programming
21
Compiling
22
Simulating/ Debugging
• Simulator (Simulating)
– A software application
– Simulates the microcontroller
– Can be run (all or step-by-step) the program on
the simulator
• Debugging
– Find errors by running step-by-step
– Can be able to see all changes in each step
23
Simulators
24
Addressing Modes
25
Jump Instructions
Command Description
JZ Jump if A=0
JNZ Jump if A/=0
DJNZ Decrement and jump if A/=0
CJNE A, byte Jump if A/=byte
CJNE reg, #data Jump if byte/=#data
JC Jump if CY=1
JNC Jump if CY=0
JB Jump if bit=1
JNB Jump if bit=0
JBC Jump if bit=1 and clear bit
26
Time Calculation
• As a Counter:
27
Software Delays
• Set of Instructions/Loop
• Easy to implement
• Delay created by executing instructions (DJNZ)
• Keep PC busy
• Can be used when timers in use for some other
task (Ex: PWM Generation)
28
Software Delay Calculation
Example:
DELAY_LOOP: MOV R1,#pH
LOOP2: MOV R2,#qH ;Inner-loop
LOOP1: DJNZ R2,LOOP1 ;Outer-loop
DJNZ R1,LOOP2
* p and q are integers
Calculation:
Inner loop:
2 x q = 2q machine cycles
Outer loop:
total machine cycles = (2q+2+1)p–1
29
Using Timers
30
More about Hardware
31
Fetch – Execute Cycle
OPCODE OPERANDS
Instruction
Fetch Execute
Program
ORG 7000H
MOV R1, #10H
PC
MOV A, R1
…………………..
Fetch Execute …………………..
…………………..
…………………..
Decode
32
Flags
33
Implementing a Hardware System
Block Diagram
Flow Chart
Testing/ Program
Debugging
Implement
34
Winding Up!
• Refer course materials
• Refer given Reference Books (If you need)
• Search for other resources for more information
(internet, books, etc)
• Discuss with others
• Understand and then write the assignments/ Lab
Reports (Do not copy) by your own words
• Complete all parts of the Assignments
• During the lab sessions, do practical by your own.
– If you don’t understand something, ask form the
demonstrator/instructor.
35
Thank You!
CJ Basnayakage: cjbas@ou.ac.lk
DS Wickramasinghe: dswic@ou.ac.lk
Phone: - Direct: 011 288 1437
Ext: 437
NI Vithanage: nivit@ou.ac.lk
36