Hi, I'm trying to generate a 40 kHz square wave with timer0 but can not get the pin5 goes well, I get double the pin6, which if successful.
Thanks for the help and best regards, I am a beginner.
This is my code:
void setup()
{
DDRD = 0b01100000;
TCCR0A = _BV(COM0A0)| _BV(COM0B1) | _BV(WGM01) | _BV(WGM00) ;
TCCR0B = _BV(WGM02) | _BV(CS00);
OCR0A = ((F_CPU / 2) / 40000L) - 1;// 199
OCR0B = OCR0A/2 ;
}
void loop()
{}