92 create 92 PERTINENT REGISTER DESCRIPTIONS 165 93 Create a

9.2 create 9.2. PERTINENT REGISTER DESCRIPTIONS 165 9.3 Create a func that initializes timer 1 based on ues determined in problem9.1. an ISR for time 1.

Solution

1. From the register description, it seems we are taking about Atmega16. Atmega16 have a 16 bit timer/counter Timer/Counter1. We want to operate this register in CTC mode with interrupt enabled. The value of the Timer/counter control registers A and B are:
TCCR1A
0. Bit 7
0
0
0
0
0
0
0. Bit 0


First two bits disable OC1A pin, second two bits disable OC1B pin. Bit 1, 0 of TCCR1A and bits 4, 3 of TCCR1B set the mode of timer/counter (CTC mode).
TCCR1B
0
0
0
0
1
1
0
1


Bits 2, 1, 0 of TCCR1B set the pressure value of 1024.

For getting one interrupt per second, we need to set the value of OCRA register.
Rate of interrupt = fcl/(N * (1 + OCRA)) = 1Hz
where fcl is clock frequency which we assume to be 16 MHz in our case
N is prescaler, 1024
Thus OCRA comes out to be 15624 or 0x3D08 in hexadecimal.

In order to enable the interrupt, bit 5 of TIMSK1 should be set to 1.
TIMSK1
0
0
0
0
1
0
0
0

2. void initialize ( ) {

TCCR1A=0X00;

TCCR1B=0X0D;

OCR1A=0X3D08;

TIMSK1=0X10;

}

 9.2 create 9.2. PERTINENT REGISTER DESCRIPTIONS 165 9.3 Create a func that initializes timer 1 based on ues determined in problem9.1. an ISR for time 1. Soluti
 9.2 create 9.2. PERTINENT REGISTER DESCRIPTIONS 165 9.3 Create a func that initializes timer 1 based on ues determined in problem9.1. an ISR for time 1. Soluti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site