My requirement of 125Khz125 kHz is satisfied, but I am just curious to know why the sketch not working as it should ...
According to my measurements, it is. Using this slightly modified version of your code:
// A sketch that creates an 8MHz8 MHz, 50% duty cycle PWM and a 250KHz250 kHz,
// 6bit6-bit resolution PWM with varying duty cycle (changes every 5μs5 µs
// or about every period.
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
pinMode(3, OUTPUT); // outputOutput pin for OCR2B
pinMode(5, OUTPUT); // outputOutput pin for OCR0B
// Set up the 250KHz250 kHz output
TCCR2A = bit(COM2A1) | bit(COM2B1) | bit(WGM21) | bit(WGM20);
TCCR2B = bit(WGM22) | bit(CS20);
OCR2A = 63;
OCR2B = 31;
// Set up the 8MHz8 MHz output
TCCR0A = bit(COM0A1) | bit(COM0B1) | bit(WGM01) | bit(WGM00);
TCCR0B = bit(WGM02) | bit(CS00);
OCR0A = 1;
OCR0B = 0;
}
I get the predicted 8 MHz output on pin 5:
And the 250 kHz output on pin 3:

