ECE 4760: Homework 2
- Explain how you will use the timer 1 capture feature to measure frequency.
- Make a spreadsheet of the states of each i/o pin for each measurement type (voltage, frequency, resistance).
- The circuit given in lab 2 fixes the threshold of the comparator (pin B3) at Vcc/2.
Draw an RC circuit, which instead, applies a voltage to B3 approximately equal to the average value of the input.
- The following code sets up timer2 to produce a square wave with no further software intervention.
Explain in detail what each statement does and why it is necessary.
What is the frequency of the square wave?
OCR2A = 99 ;
TCCR2B = 1;
TCCR2A = (1<<COM2A0) | (1<<WGM21) ;
DDRD = (1<<PIND7) ;
- The following code sets up timer1 to capture the time of comparator transitions
Explain in detail what each statement does and why it is necessary.
TCCR1B = (1<<ICES1) + 1;
TIMSK1 = (1<<ICIE1) ;
ACSR = (1<<ACBG) | (1<<ACIC) ;
DDRB = 0 ;
Copyright Cornell University
January 5, 2012