The objective of this problem is to measure body temperature using input capture (pulse-width measurement) (Figure 6.25). A shunt resistor is placed in parallel with a thermistor. The thermistor-shunt combination R has the following linear relationship for temperatures from 90 to 110°F.
Figure 6.25
![850_139382f5-9ef8-4308-81da-4b9db063e4e2.png](https://secure.tutorsglobe.com/CMSImages/850_139382f5-9ef8-4308-81da-4b9db063e4e2.png)
In other words, the resistance varies from 100 k
to 80 k
as the temperature varies from 90 to 110°F. The range of your system is 90 to 110°F and the resolution should be better than 0.01°F. You will use a 74HC123. On the rise of the B trigger input, the 123 creates a negative logic pulse on its output. The width of the pulse is about 0.28⋅R⋅C. Temperature will be measured 100 times a second
a) The pulse-width measurement resolution will be 125 ns for the 9S12. Choose the capacitor value so that this pulse width measurement resolution matches the desired temperature resolution of 0.01°F.
b) Given this value of C, what is the pulse width at 90°F? Give the answer in both microseconds and E clock cycles.
c) Given this value of C, what is the pulse width at 110°F? Give the answer in both microseconds and E clock cycles.
d) Write the ritual that configures an output compare on PT1 as a periodic interrupt. A rising edge should occur every 10 ms. Configure an input capture on PT0 to measure the pulse width.
e) Show the interrupt handler(s) that perform the temperature measurement tasks in the background and sets a global, Temperature, 100 times a second. The units of this unsigned decimal fixed point number are 0.01°F. For example, Temperature will vary from 9000 to 11000 as temperature varies from 90 to 110°F. The output compare interrupt will start the pulse (You may assume the interrupt vectors are properly established, but please use simple interrupt handler names like TOC1handler() and TIC0handler().