Hi, I am playing around with the app and notice Arduino Nano's PD3, which is controlled by Timer2 (base clock ~31Khz) returns wrong frequency.
According to documentation, TCCR2B = 110 should set the divisor to 256, thus PD3 should have a frequency of 122.55Hz, but the simulator shows 244.14 Hz.
Images:
Source code (Pascal, but should be easy to translate to C)
According to documentation, TCCR2B = 110 should set the divisor to 256, thus PD3 should have a frequency of 122.55Hz, but the simulator shows 244.14 Hz.
Images:
- Spoiler:
Test with a toy oscilloscope, which shows result very close to official documentation:
Source code (Pascal, but should be easy to translate to C)
- Code:
begin
// Configure PD3 as output
DDRD := DDRD or %1000;
// Configure PD3 in PWM mode
TCCR2A := (%10 shl COM2B) or (%1 shl WGM0);
// Enable timer 2, clock speed / 256
TCCR2B := %110;
// Duty cycle = 50%
OCR2B := 128;
repeat until False;
end.