# Understanding timer configuration

I have this code that I am trying to understand , say -i- is looping from 0-100, then you have this (we already setup the timer stuff):

`````` TCNT1 = 0;
ICR1 = i;
OCR1A = i/2;
``````

Say we also using a pre sacle of 1, with 16MHz clock , on timer 1.

According to the OCR1A , the values will be- 0,0,1,1,2,2,3,3,4,4,5,5... etc. Is that right ?
Is this means that the frequency is 16MHz,16MHz,8MHz, 8MHz ,4MHz, 4MHz, 2Mhz, 2Mhz... ?

What the ICR1 do, I could not really understand, and I also guess I dont get what frequencies will this code produce ?

Thank you.

we already setup the timer stuff

You have not provided the code which indicates the mode and other set up parameters of timer 1 which will determine the frequency and output.

In general, if the timer is in a mode using ICR1 as top value, ICR1 will be controlling the frequency, and OCR1A will be controlling the output duty cycle

Assuming the TimerCounter1 is set up for FastPWM with ICR1 as TOP the 'i' value is setting the frequency and the duty-cycle is set to (roughly) 50%. I think the formula is something like (16 MHz/(i+1))/2 so 0=8 MHz, 1=4 MHz, 2= 2.66 MHz, 3=2 MHz, 4=1.6 MHz