I’m trying to follow a guide on setting up fast PWM on an Atmega328p. The guide is here: PWM On The ATmega328 - QEEWiki
I’ve put in the example code witch should output a frequency of 8Mhz (16Mhz/8/256=7812.5Khz). I’m measuring only 976Hz as if there was an extra divider or larger prescaler than was specified. I’m using a sound card scope to measure the frequency.
I reburned the bootloader and even verified with the board detector sketch that the fuse settings are correct. Fuses are set to FF DE FD as specified in boards.txt
I have this code in the IDE:
void setup()
{
DDRD |= (1 << DDD6);
OCR0A = 128;
// set PWM for 50% duty cycle
TCCR0A |= (1 << COM0A1);
// set none-inverting mode
TCCR0A |= (1 << WGM01) | (1 << WGM00);
// set fast PWM Mode
TCCR0B |= (1 << CS01);
// set prescaler to 8 and starts PWM
//16MHz/8/256 = 7812.5Khz
}
void loop()
{
// put your main code here, to run repeatedly:
}
Why am I not getting the desired frequency?