I want to make a buzzer toning with timer as pwm on PD4
it doesn't make any sound at all
but when i connect it to PD5 it makes sound with different levels as OCR1A values change
i think it doesn't work as pwm with those configuration
i'm using 8MHz F_CPU and prescaling of 64
or any ideas about sample code as interrupt to use PD5 for a buzzer and a Led if possible
This my code , What seems to be the problem
#define F_CPU 8000000UL /* Define CPU Frequency e.g. here its 8MHz */
#include <avr/io.h> /* Include AVR std. library file */
#include <stdio.h> /* Include std. library file */
#include <util/delay.h> /* Include Delay header file */
int main(void) {
DDRD |= (1<<PD4);
TCNT1 = 0; /* Set timer1 count zero */
ICR1 = 2499; /* Set TOP count for timer1 in ICR1 register */
/* Set Fast PWM, TOP in ICR1, Clear OC1A on compare match, clk/64 */
TCCR1A = (1<<WGM11)|(1<<COM1A1);
TCCR1B = (1<<WGM12)|(1<<WGM13)|(1<<CS10)|(1<<CS11)|(1<<COM1B1);
while(1) { OCR1B = 200;
_delay_ms(500);
OCR1B = 100;
_delay_ms(500);
}
}