






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







This exercise will practice the MC6811 functions for time measurements. Input capture (IC) and output compare (OC) functions will be reviewed and applied to measure a bolt drop and to generate a square wave. Part I will review the groundwork. Part II will perform time measurements on a dropping bolt using input capture (IC) timer functions. Part III will generate a square wave using output compare (OC) timer functions.`
___________________________________________________________________ 2 point(s) e) How long does one count last? ______ s 2 point(s) f) What is the maximum time duration that TNCT can measure between two consecutive overflows? ___________ s = ___________ ms. 2 point(s)
a) Describe the Input Capture (IC) concept:
__________________________________________________________________2 point(s) b) How many IC channels are there in 68HC11 MCU? ______ 1 point(s) c) Which port in MCU is related to IC function? ______ 1 point(s) d) What happens with the IC registers at MCU reset? __________________________1 point(s) e) Can you change the value in an IC register? ____Y ____N 1 point(s) f) To set up IC1 for detecting a rising edge: Which Timer control register needs to be used? ______ 1 point(s) What function do EDGxB and EDGxA perform? _____________________1 point(s) What value needs to be put into the control register? ___________2 point(s) The physical pin corresponding to IC1 is: ______ 1 point(s) Which IC flags (ICxF) is related to IC1? _________ 1 point(s) When does this input capture flag get set? __________________________2 point(s) In which register is the capture time going to be stored? ___________1 point(s)
______________________________________________________2 point(s) b) How many OC channels are there in 68HC11 MCU? ______ 1 point(s) c) What happens with the OC registers at MCU reset? _______________1 point(s) d) Can you change the value in an OC register? ______Y _____N 1 point(s) g) To set up OC2 for generating a toggle signal: Which Timer control register needs to be used? ______ 1 point(s) What function do OMx and OLx perform? _____________________1 point(s) What value needs to be put into the control register? ___________2 point(s) In which register is the output time stored? ___________1 point(s) The physical pin corresponding to OC2 is: ______ 1 point(s) Which OC flags (OCxF) is related to OC2? _________ 1 point(s) When does this OC flag get set? __________________________2 point(s) e) What are the masks for output compare flags (OCxF)? Fill the table below: 2 point(s) OC1F % OC2F % OC3F % OC4F %
Note: This program is based on the example Ex_IC and previous examples regarding the use of Port B and of SCI. Before performing the present program, review, run, and thoroughly understand the coding in example Ex_IC. MC6811 will be used in an experiment to measure travel times. A 1.5-in bolt will be held by an electromagnet at the top of a drop shaft. The electromagnet is connected to the MCU. This magnet is controlled by any of the 8 pins on PORTB. It is turned on by sending 5V through parallel PORTB. When a keystroke occurs, the MCU commands the electromagnet to release the bolt. Simultaneously, the time origin, T0, is recorded. The bolt travels down the shaft. After falling a specified distance (L = 48.75-in), the bolt crosses an infrared emitter-detector sensor and interrupts its beam causing its output voltage to fall from high (+5V) to low (~0V). When the bolt exits the emitter detector sensor, its output voltage comes back up to high (+5V). The output from the emitter-detector sensor is wired into the input capture pins IC1 and IC2 of the MCU. You will program the microprocessor to perform the following functions: (a) Control the electromagnet (b) Take the initial time when the process starts (c) Measure the time when the free-falling bolt reaches the emitter-detector (d) Measure the time the bolt passes through the emitter-detector Electronics Electromagnet Emitter-detector sensor Drop shaft Figure 1 Bolt drop experimental setup
EXECUTION Open THRSim11. Close the Commands window. View ports registers and serial registers, serial transmitter, serial receiver, IO box, Port A pins, timer registers, memory locations$0000-$0007. Set display of TCTL2, TFLG1, TFLG2 to binary. Arrange windows for maximum benefit: Open and assemble your program. Reset. Set standard labels. Set breakpoints as follows: Just after the bolt has been released Just after the first input capture Just after the second input capture At SWI i) Toggle the value of Pin PA2/IC1 from "0" to "1" by double clicking on it. This simulates the signal that the Input capture registers are from the emitter detector sensor. ii) Run your program in the simulator. The program should be looping at the beginning showing that it is waiting on the keystroke. You should also notice the value of Port B in the I/O box. The red lights should be on, ensuring that of the electromagnet is on. iii) Once the program is running, enter character S into the serial transmitter window and click Send. The keystroke detection loop should be exited, and your program should stop at the first breakpoint. iv) Step through the program. Port B lights should turn off and the value of the TCNT should be stored in TIME0. v) Run. The program should then begin the loop looking for the first input capture, while also verifying for timer overflows and incrementing NOF1 when they occur. Let this part of the program run for a while. Watch as the TCNT changes from $ffff to $0000. This should cause your program to increment your timer overflow counters NOF1 and NOF2. vi) Trigger the first input capture by toggling the value of Pin PA2/IC1 in the Port A Pins window from "1" to "0" (double clicking on it). The MCU should see this as the awaited transition on IC1, and the flag IC1F flag should get set. The first input capture loop should be exited, and your program should stop at the breakpoint. vii) Step through the program. Observe the value of TIC1 be stored in TIME1. viii) Run again. Your program should loop looking for the second input capture, while also verifying for timer overflows and incrementing NOF2 when they occur. ix) Trigger the second input capture by changing the value of Pin PA1/IC2 in the port A Pins window from "0" to "1". This should cause the second input capture loop to be exited and the program to stop at the next break point. x) Step through the program and watch the value of TIC2 being stored in TIME2. Your program should terminate. xi) Reset and run your program again. This time, after each stop at the breakpoint, simply press the run button and let it go on. Verify that your program runs well. Do any corrections necessary.
Use the flowchart to code your program in the simulator using the standard template. Save the program in the personalized file name LASTNAME_Firstname_OC_sqwav.asm. Write or paste your coded program below. 5 point(s)
Open THRSim11. Close the Commands window. View CPU registers, timer registers, port A pins, memory list. Open and assemble your program. Set breakpoints at Just after output compare happens At SWI Reset registers and memory. Set standard labels. Set display of TCTL1, TFLG1 to binary. Arrange windows for maximum benefit: Press the RESET button. a) Run your program and verify it in a manner similar to Ex_OC and verify that it works as expected b) Use the calculation patterns of Ex_OC to complete the information in Table 1. Insert your calculations below. 10 point(s) Hex Number $0100 $1000 $8000 $a000 $ffff $ _____ $ _____ Half wavelength duration (s)
Frequency (Hz)
T = Theoretical, from your calculation; E = Experimental, from your O-scope reading.