Closed urish closed 3 years ago
When you stop a timer (by setting the CS bits to 0), the counter should keep running until the current instruction execution completes.
Here is a small Arduino program that reproduces the issue:
void setup() { byte tcnt = 0; asm(R"( EOR r1, r1 LDI r16, 0x1 ; TCCR2B = 1 << CS20; STS 0xb1, r16 ; Should start counting after this instruction STS 0xb1, r1 ; Should stop counting after this instruction NOP NOP LDS %0, 0xb2 ; TCNT should equal 2 at this point )": "=r"(tcnt)); Serial.begin(115200); Serial.print("Result: "); Serial.println(tcnt); } void loop() { }
When running on silicone, the output is Result: 2. However, running inside the simulation, you get: Result: 0.
Result: 2
Result: 0
When you stop a timer (by setting the CS bits to 0), the counter should keep running until the current instruction execution completes.
Here is a small Arduino program that reproduces the issue:
When running on silicone, the output is
Result: 2
. However, running inside the simulation, you get:Result: 0
.