I need to generate an 8-channel PWM using ATMega16A. As you know, this MCU has only three timers, and I want to avoid using timer0. So Timer1 and 2 would be needed. I have been doing research on this, but haven't had success so far. I would like to hear your suggestions on this. If you have any ideas o any related reference I could read. Below you can see what I consider my skeleton for the code. I know I have to use interrupts, but still not sure how to implement them. I plan to output the PWM signals through Port A, that is, PA0 to PA7. I attach a picture for you to have an idea. The application of this is to control several RC Servos at 50 Hz PWM frequecy. I would appreciate your help. Thank you.

According to the interwebs, min pulse is 1ms, max pulse 2ms. With a prescaler of 8, you get a resolution of 1us. This is far better than the average servo can achieve. With a prescaler of 1 you get a resolution of 125ns. Clearly overkill, but the result is the same. Try both and decide for yourself.

That got me a little confused again, but it's okay. I will see what I can do by myself. Thank you so much.

The key to understanding the code is to understand how the timer is working and, importantly, what gets loaded where and when. Read the datasheep and in particular the table headed 'Waveform Generation Mode Bit Description'.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

Still not clear about the value of ICR1 I have to load for my application. Previously, I was able to get a single PWM @50Hz changing the pulse width from 800uS to 2200us and it worked well. But with this issue of having 8 channels, I have found it complicated.

It helps if you draw yourself a timing diagram. It is hard to juggle many things in your mind at once.
As for the icr1 value either 19999 with a prescale of 1 or 2499 with a prescale of 8. Look at your timing diagram you posted earlier as this shows the timing sequence. The timer ovf is the start of the pulse. The compare is the end of the pulse. The icr1 value sets the time between pulses at 2.5ms. 8 times 2.5ms is 20ms or 50Hz.

It helps if you draw yourself a timing diagram. It is hard to juggle many things in your mind at once. As for the icr1 value either 19999 with a prescale of 1 or 2499 with a prescale of 8. Look at your timing diagram you posted earlier as this shows the timing sequence. The timer ovf is the start of the pulse. The compare is the end of the pulse. The icr1 value sets the time between pulses at 2.5ms. 8 times 2.5ms is 20ms or 50Hz.

Now I'm getting the idea. In my case I chose 19999 with a prescale of 1. I understood that OVF is the start of the pulse and compare the end.

So, I think that it should work now. I will see if I can draw the time diagram. I suppose now my signals should be present through PA0-PA7.