
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!

Project Two Timing M easurements Page 1 of 1
Complete by: References: Wednesday January 14 thfor an A+ Section 4.7 A Calibrated Delay Macro Section A1.7 Watch Variables
Overview for P2.c
For this project you will modify the T1A.c code to form a new file called P2.c. In the Initial function after the initialization of OSCCON , add the line OSCTUNE = 0x00; After calibrating this variable “by hand” using QwikBug, you will go back and modify this initialization so that a subsequent reset and running of the chip will include this modification.
Note from page 52 that for any value less than 256, the Delay macro will be executed in (10 times that value) clock periods
Change the code in the main loop to nothing more than PORTBbits.RB3 = 1; Delay(10); PORTBbits.RB3 = 0; Sleep(); Nop(); The Nop command is inserted because the CPU sometimes fails to execute the first instruction after awakening after a Sleep command. (The command to jump back to the beginning of the loop must not be skipped over without being executed. The Nop command can be executed or ignored with impunity, possibly inserting an extra CPU cycle but otherwise doing nothing.)
Calibration of the CPU clock period
After compiling P2 and downloading it to the 4321 chip using QwikBug, set up OSCTUNE as a watch variable so that you can pause, change the value of OSCTUNE, and run with the new value.
Run P2 and monitor the CPU clock Fcpu (= Fosc/4) by probing test point TP6. Set up the scope to measure and display the period of the waveform. Fill in the chart on the attached checkout sheet with period versus OSCTUNE values.
Delay Macro Check
Follow the procedure on the checkout sheet to measure the time interval inserted into code execution via the macro Delay(10).
Sleep/Awaken/Loopback Overhead Time
Finally, follow the checkout sheet procedure to determine the amount of awake time used to put the chip to sleep, to awaken, and get back to the beginning of the main loop.