Problem 1 (35 points)
[CL02]
Based on the AVR code given below, answer the questions that follow:
// Problem 1
#define FCPU 8000000UL
#include <avr/interrupt.h>
int time_cntr = 0;
int main() {
TCCR0 = 0x03;
TCNT0 = 0x00;
DDRB = 0xFF;
while(1) {
ISR(TIMER0_OVF_vect) {
TCNT0 = 6;
if(time_cntr++ == 500) {
PORTB = PORTB | 0x10;
time_cntr = 0;
}
}
}
}
1. What is the prescaler value and, as a result of this value, what clock signal is specified in Hz and applied to Timer0? [5 points]
2. After how many seconds does the Timer0 interrupt occur? Explain your answer. [5 points]
3. What is the frequency of the waveform generated at Port B pin 4? Show calculations. [10 points]
4. Achieve the same task (by rewriting the program) using the polling method. [15 points]