Docsity

Microcontroller Apps: HW Assignment 4 - Software Switch/Line Debounce & Handshaking - Prof, Assignments of Microcomputers

Toggle sidebar
bg1
ECE4510/5530
MicrocontrollerApplications
Homework Assignment #4 Due Wednesday, May 20
Homework Programming Objective: Software controlled switch/line debounce and
microcontroller handshaking using the ECT.
Part 1: The same as homework #3, except use the ECT for all timing delays.
You are to design the circuitry and software for writing to a tri-state bus that could be used when
communicating with another microcontroller when the other microcontroller is the “bus master”.
In this operation, the bus master will provide a handshaking signal, H1, (Port M pin4). When H1
is high, no action is taken, when H1 transitions from high-to-low (1=> 0) it may by due to a
switch bounce. Therefore, after first observing the high-to-low transition, you must wait for 10
usec and recheck the signal. If it is still low, it is a request for data from your processor. If it is
not still low, it was a glitch and should be ignored.
When a high-to-low has been accepted, you must in the following sequence (1) output an 8-bit
word to Port T, (2) generate an ENABLEn signal (Port M pin0) that transitions from high-to-
low, remains low for 60 usec and then transitions from low-to-high where it remains until the
next H1 high-to-low cycle, and (3) generate an H2 signal (Port M pin1) that transitions from
low-to-high 10 usec after the ENABLEn signal remains low and transitions from low-to-high 10
usec before the ENABLEn signal. The timing diagram for this sequence is shown in Figure 1.
H1
ENABLEn
H2
Glitch, not acted on
10 usec intervals
SW handshake test passes
Bus Port T Values
Figure 1. Desired system timing
For hardware, connect the Port T outputs to a ‘540 or ‘541 buffer as used in Lab 3 and 4, connect
the ENABLEn signal to OE1n of ‘540 or ‘541, plus 10 kohm pull-up resistors on the output of
pf2

Partial preview of the text

Download Microcontroller Apps: HW Assignment 4 - Software Switch/Line Debounce & Handshaking - Prof and more Assignments Microcomputers in PDF only on Docsity!

ECE 4510/

Microcontroller Applications

Homework Assignment #4 Due Wednesday, May 20

Homework Programming Objective: Software controlled switch/line debounce and microcontroller handshaking using the ECT.

Part 1: The same as homework #3, except use the ECT for all timing delays.

You are to design the circuitry and software for writing to a tri-state bus that could be used when communicating with another microcontroller when the other microcontroller is the “bus master”. In this operation, the bus master will provide a handshaking signal, H1, (Port M pin4). When H is high, no action is taken, when H1 transitions from high-to-low (1=> 0) it may by due to a switch bounce. Therefore, after first observing the high-to-low transition, you must wait for 10 usec and recheck the signal. If it is still low, it is a request for data from your processor. If it is not still low, it was a glitch and should be ignored.

When a high-to-low has been accepted, you must in the following sequence (1) output an 8-bit word to Port T, (2) generate an ENABLEn signal (Port M pin0) that transitions from high-to- low, remains low for 60 usec and then transitions from low-to-high where it remains until the next H1 high-to-low cycle, and (3) generate an H2 signal (Port M pin1) that transitions from low-to-high 10 usec after the ENABLEn signal remains low and transitions from low-to-high 10 usec before the ENABLEn signal. The timing diagram for this sequence is shown in Figure 1.

H

ENABLEn

H

Glitch, not acted on

10 usec intervals

SW handshake test passes

Bus Port T Values

Figure 1. Desired system timing

For hardware, connect the Port T outputs to a ‘540 or ‘541 buffer as used in Lab 3 and 4, connect the ENABLEn signal to OE1n of ‘540 or ‘541, plus 10 kohm pull-up resistors on the output of

the buffer (pulling the “bus” high when the ENABLEn signal is high), and use another ‘540 or ‘541 as a buffer for H2.

You should consider the Adapt9S12DP512 Board with the CPU E-clock set to 8MHz (one cycle time is approx. 125ns).

Homework try points:

(a) Write a software C function that will read the TCNT, define a future count based on a desired delay and write the compare function for one of the ports.

(b) Write a ECT compare function interrupt routine that sets a software compare flag when the interrupt occurs.

(b) Write a software code segment that monitors H1 (Port M pin4) reading it regularly in a loop while it remains high. When it sees a high-to-low transition, stop looping, set an ECT compare for 10 usec and enter another loop that will execute until the software compare flag of part (b) is set. After exiting the loop, if the H1 value is one, return to the monitoring loop. If not, “continue”.

(c) Write a software code segment that makes ENABLEn (Port M pin0) transition from high-to- low, sets an ECT compare for 10 usec and enter another loop that will execute until the software compare flag of part (b) is set..

(d) Write a software code segment that makes H2 (Port M pin1) transition from high-to-low, sets an ECT compare for 40 usec, enter another loop that will execute until the software compare flag of part (b) is set, and then makes H2 transition from low-to-high..

(e) Write a software code segment , sets an ECT compare for 10 usec, enter another loop that will execute until the software compare flag of part (b) is set and then makes ENABLEn (Port M pin0) transition from low-to-high.

(f) Combine the code segments into a program that performs the stated objective of Part 1. Turn in your assembled .lst file.

(g) Draw the hardware schematic for the defined system.