Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

art2: Program tracing (10 points 2-2-2-2-2) Consider the following program. | 1

ID: 2293207 • Letter: A

Question

art2: Program tracing (10 points 2-2-2-2-2) Consider the following program. | 1 a) Explain why in line 23, we set TOIE1 to 1. #include #includecavr/ interrupt . h? 2 | b) Are we using pre-scaling for Timer1? Justify your answer for Timert? uatify your SR (TMERL OVE, vect) if (PORTC & 64 64) ( TCNT1H 8xC1; TCNT1L 9x88; 6 ) else ( If no interrupt occurs, what will the microcontroller be busy doing? c) TCNT1H 0x85; TCNT1L 8xEE 10 12 13 14 15 16 int main(void) 17 18 19 20 d) On which PIN this program produces a square signal? PORTC ^# 64; The duty cycle of the generated signal is not 50%. Justify. e) DDRD 0xFF; TCCR18 1; sei ); f) 4 points bonus question. Find the Duty cycle of the 21TCCR1A generated signal 23 24 25 26 27 28 ) while (1) PORTD PINB;

Explanation / Answer

a). Enable timer1 overflow interrupt(TOIE1). This means that we can do something at the frequency that we want.

b).TCCR1B is set to 1 that means CS10 = 1, So no prescaling is used.

c). All the timers in Arduino microcontroller and in every microcontrollers are a simple counters. These counters are increased usually by the main clock of the microcontroller. Every time we have a clock cycle – the time between two adjacent pulses of the main oscillator the counter increases according to the prescaler set for those timer.

d).Square wave appear at PORT D.