+ All Categories
Home > Documents > WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Date post: 19-Jan-2016
Category:
Upload: philomena-mccarthy
View: 214 times
Download: 0 times
Share this document with a friend
59
WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers
Transcript
Page 1: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

WEEK 2

Jump, Loop, and Call Instructions

ET2640 Microprocessors and Microcontrollers

Page 2: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 3: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 4: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 5: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 6: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 7: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

I/O Port Programming

ET2640 Microprocessors and Microcontrollers

Page 8: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Peripherals

• Know the device peripheral parameters• Resolution of data• Frequency of measurement• Understand the interface issues

Page 9: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 10: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 11: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 12: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 13: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 14: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 15: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 16: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 17: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 18: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 19: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 20: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Page 21: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2460 Microcomputers and Microprocessors

COUNTER/TIMER PROGRAMMING IN THE 8051

Page 22: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Outlines

• List the timers of the 8051 and their associated registers

• Describe the various modes of the 8051 timers• Program the 8051 timers to generate time

delays• Program the 8051 counters as event counters

Page 23: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

PROGRAMMING 8051 TIMERS

Timer 0 registersTL0 ( timer 0 low byte )TH0 ( timer 0 high byte )

Page 24: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Timer 1 registersTL1 ( timer 1 low byte )TH1 ( timer 1 high byte )

Page 25: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

TMOD (timer mode) register

Page 26: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 27: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Find the timer’s clock frequency and its period for various 8051-based systems, with the following crystal frequencies:A. 12 mHzB. 16 mHzC. 11..592 mhz

Page 28: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

ET2640 Microprocessors and Microcontrollers

Oscillator/Clock

Page 29: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Example:

Find the value for TMOD if we want to program timer 0 IN MODE 2 USE THE 8051 XTAL for the clock source, and use instructions to start and stop the timer

TMOD-0000 0010 ;Timer 0, mode 2C/T=0 to use XTAL clock source, and Gate-0 to use internal softwareStart and atop method.

Page 30: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Mode 1 programming1.Loaded value into TL and TH2.”SETB TR0” for timer 0 ;”SETB TR1” for timer 13.If TF (timer flag) = high “CLR TR0” or “CLR TR1”4.Reloaded TH and TL value, TF reset to 0

Page 31: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Steps to program in mode 11.Load the TMOD value2.Load registers TL and TH 3.Start the timer (SETB TR0 or SETB TR1)4.Keep monitoring the timer flag (TF)5.Stop the timer (CLR TR0 or CLR TR1)6.Clear the TF flag7.Go back to step 2

Page 32: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Calculate Timer Delay

Page 33: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 34: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 35: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 36: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 37: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 38: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 39: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 40: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Finding values to be loaded into the timerAssuming XTAL =11.0592MHz from Example 9-10

1.Divide the desired time delay by 1.085μs2.Perform 65536-n, where n is the decimal value we got in Step 13.Convert the result of Step 2 to hex, where yyxx is the initial hex value to be loaded into the timer’s registers4.Set TL = xx and TH = yy

Page 41: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 42: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 43: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 44: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Mode 0

Like mode 1 except that it is a 13-bit timer

Mode 2 Programming

1.Loaded value into TH (8-bit timer)2.”SETB TR0” for timer 0 ;”SETB TR1” for timer 13.If TF (timer flag) = high “CLR TR0” or “CLR TR1”4.Reloaded TL value kept by TH

Page 45: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Steps to program in Mode 2

1.Load the TMOD value2.Load the TH registers 3.Start the timer4.Keep monitoring the timer flag (TF)5.Clear the TF flag7.Go back to step 4

Page 46: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 47: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 48: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 49: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 50: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

C/T bit in TMOD register

Page 51: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 52: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 53: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 54: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 55: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 56: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 57: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.
Page 58: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

The case of GATE =1 in TMOD

Page 59: WEEK 2 Jump, Loop, and Call Instructions ET2640 Microprocessors and Microcontrollers.

Recommended