Closed urish closed 4 years ago
Issue reproduced by the following assembly code:
NOP
NOP
NOP
NOP
LDI r16, 0x1 ; TCCR2B = 1 << CS20;
STS 0xb1, r16 ; Should start counting after this line
NOP
LDS r17, 0xb2 ; ; TCNT should equal 2 at this point
LDI r16, 0xff
OUT 0xa, r16
OUT 0xb, r17
loop:
RJMP loop
When running this code, we get 9
in the simulator, but 2
on an Uno board.
Reproduction sandbox: https://avr8js-asm-issue-41.stackblitz.io
Use the following code to reproduce:
On a physical ATmega328p this code prints 1, as the counter only starts counting after we set the prescaler in the first line of
main()
. In the simulation, however, the same code prints 22, as the timer is counting even before the prescaler is set.