Two entirely different things, you should open separate posts.
Anyways, about timer calculation, it is described in every AVR datasheet, 30 pages or so for each timer. The question is too general, there are a lot of modes and a lot of equations given in the datasheet, I suggest you start reading them.
In addition, there are a couple of really helpful tutorials you could look into.