Question: Write a C program for the A T 9 0 that uses the input captures system of the 1 6 - bit timer / counter

Write a C program for the AT90 that uses the input captures system of the 16-bit
timer/counter to measure the frequency at pin ICP1(=PD4).
Pin PD4 is connected to a PWM frequency generator of the lab board. The generator has 16
settings that differ in frequency (up to 400kHz) and duty cycle. Button "FREQ SEL" allows you
to change between settings. The current setting is displayed as a hexadecimal number on the
component labelled "FRQ".
Example settings:
Setting 0= off
Setting 1=1Hz wave
o Setting 5=1kHz wave
The frequency is measured using the "frequency method" from the lecture: Over a certain
measurement duration d, the number e of rising edges are counted.
The frequency f is displayed in Hz as an 8-bit value on the LED panel (Port C).
To account for frequencies that exceed the 8-bit range, the switches on Port A can be used to
change the unit (e.g. to 0.1Hz,1Hz,100Hz).
Values higher than 255 are displayed as 255. Hence, a value of 255 indicates that the
switches should be used to change to another unit.
More specifically, the switches effect the
measurement duration d,
timer/counter prescaler, and
a multiplier for the displayed value f
as follows:
Switch PA7 switches between a 'configuration mode' and a 'measurement mode'.
In the 'measurement mode', the white lamp (PB6) is turned on to indicate ongoing
measurements. Measurements are being taken repeatedly until PA7 is turned to
'configuration mode'. Whenever the frequency measurement is updated, the value is
displayed on Port C.
In the 'configuration mode', the white light is off and no frequency measurements
are conducted. Instead, the user can configure the measurement process via
switches PA0, PA1, PA2, PA3. The LEDs on PC0, PC1, PC2, PC3 light up according to
the switch positions.
If PA0= off, then a prescaler of 8 is set (resulting in timer/counter increments every 1us).
If PA0= on, then a prescaler of 1 is set (resulting in timer/counter increments every 125ns).
PA2 and PA1 set the measurement duration as follows:
PA2= off, PA1= off d=10 measurement duration
PA2= on, PA1= off d=1 s measurement duration
PA2= on,PA1= on d=10 ms measurement duration
To handle very high frequencies, PA3= on allows to divide the number of rising edges e
detected over the measurement duration to be divided by 100 before being displayed.
 Write a C program for the AT90 that uses the input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!