fm101
Member level 5
I have the following CTC mode arduino code to generate 100khz square wave at pin 6.
But the oscilloscope shows peaked square wave at frequency 7.99MHz and the amplitude is just 765.44mV as shown below.
Using delay and microseconds function I was able to generate expected square wave with frequency. But with the above CTC mode code I am not able to generate expected square wave. What could be the problem?
C++:
void setup () {
//Pin 6 (OC0A) is output
pinMode(6, OUTPUT);
// Load 79 to generate 100 kHz sq.wave
OCR0A = 79;
// Toggle OC0A on compare match, WGM 2 (CTC mode)
TCCR0A = (1 << COM0A0) | (1 << WGM01);
// Start the timer, no prescalar
TCCR0B = (1 << CS00);
}
void loop() {
}
But the oscilloscope shows peaked square wave at frequency 7.99MHz and the amplitude is just 765.44mV as shown below.
Using delay and microseconds function I was able to generate expected square wave with frequency. But with the above CTC mode code I am not able to generate expected square wave. What could be the problem?