You are on page 1of 19

Microprocessors and Interfacing

ECX4236

Day School 02
(12th May 2016)

N. I Vithanage

Department of Electrical and Computer Engineering


The Open University of Sri Lanka
1
For Consideration

1. Mr. Sampath Wickrmasinghe (Course Coordinator) is


not available on Thursdays and Fridays.
2. There is a problem in Google calendar. Sometimes it
record AM as PM.
3. Still there are problems in Moodle Class.
4. Coping - zero marks for all parties.

2
Lab Experiment 02

• Pre Task: Complete and bring to the lab


– The task will post in google drive, moodle and will
mail individually.
• More complex assembly programs
• Interfacing
– LCD Panel, LEDs
– Driving Motors
Ex: Stepper, Servo, DC

3
Phase 02

Assignment 02 & Lab Experiment 02

4
Implementing Phase

• Implementing microprocessor based system


• 8051 Microprocessor/ Microcontroller (AES51 Development
board)
• Microcontroller Programming Techniques
• Interfacing Components

5
Delays

6
Delay Loops

• Keep processor busy for sometime


• Run some instructions
• Use resources (Ex: Registers) that does not
allocated to main/ other tasks
• Do the calculations
• Decide the resources (Ex: Registers) and
values, which needed for the delay loop

7
Time Calculations

• Crystal Frequency = 11.059 MHz

• 1 Machine Cycle = 12 Crystal Pluses

• Running timer (f) =

• Period (Time for 1 Machine Cycle):

• As a Counter:

8
Delay Loop Implementation
MOV R3, #4
Outer Loop
L3: MOV R2, #3 Inner Outer Loop
L2: MOV R1, #2 Inner Loop

L1: DJNZ R1, L1 IL = 2 x R1


DJNZ R2, L2 IOL = (IL+1+2) x R2 - 1
DJNZ R3, L3 OL = (IOL+1+1+2) x R3 - 1 - 1
Total Cycles = OL + 3
Total Time = Total Cycles x Period
9
Timers/ Counters
• Timer: Interval Timing (Delays)
Ex: Periodic delays, measurements

• Counter – Counts inputs (events occurring


outside the microcontroller)

• Baud Rate Generation (Serial Communication)

10
Timers/ Counters - SFR

Timer SFRs

11
Timers/ Counters - Modes

Timer Modes

12
Using Timers

I. Set the Timer Mode (TMOD)


II. Load Values (TH, TL)
III. Timer Initialization/ Control (TCON)
IV. Run the timer (TR)
V. Check the over-flow bit (TF)
VI. Stop the timer (TR)

13
Using Timers. cont.

T1M1 T1M0 Mode Description


0 0 0 13-bit timer
0 1 1 16-bit timer
1 0 2 8-bit auto-reload
1 1 3 Split mode

14
Using Timers. cont.

0
…………………..
…………………..
…………………..
…………………..
…………………..
65535

15
Using Timers. cont.

Case 01: Full range delay


Clock = 11.0592
Count up to (full range) = 65535
Period = 1.085 µs
Timer Delay = 65535 x 1.085 µs
= 71.105 ms

16
Using Timers. cont.
Case 02: Delay less than full range
Ex: Delay time = 20 ms
Period = 1.085 µs
Delay value = Delay Time/ Period
= 20 ms/ 1.085 µs = 18433.18
Reload Value = Full range – Delay Value
= 65535 – 18433 = 47103
= B7FFh
TH = B7h, TL = FFh
17
Using Timers in Assembly
DELAY: MOV TMOD,#0001B Select the Timer Mode
MOV TH1,#4CH
Set The Timer
MOV TL1,#00H
CLR TF1 Clear Overflow bit
SETB TR1 Timer Run
LOOP: JNB TF1,LOOP Check Overflow bit
CLR TF1
Clear all Flags
CLR TR1
RET Returning to main program

18
Thank You!

 DS Wickramasinghe: dswic@ou.ac.lk
 CJ Basnayakage: cjbas@ou.ac.lk
Phone: - Direct: 011 288 1437
Ext: 437
 NI Vithanage: nivit@ou.ac.lk

Everyday, check your e-mails, MyOusl, Moodle, Google Drive…..


Give us your feed back to improve the course…..

19

You might also like