ATmega328 Timer1 Input Capture issue
Quote from Tonigau on July 22, 2026, 9:28 pmI am having trouble getting input capture working correctly when I toggle ICES1 bit inside ISR.
Otherwise input capture working ok.Goal: Measure Duty of 25khz PWM using Timer1 ICP
Using SimulIDE V1.2.0-RC1 & ATmega328Possible SimulIDE ATmega328 Timer1 Input Capture issue
The following tests were performed on ICP1 (D8):
With 25khz, 20% Duty applied.Rising-edge capture only: PASS
Falling-edge capture only: PASS
Serial.print = 0: 0 640Alternating rising/falling by toggling ICES1 in the capture ISR: FAIL
Expected:
High time varies with duty.
Period remains constant.
Serial.print = 20: 320 640 (or close to)Actual:
High time is always one complete period.
Measured period becomes two actual periods.
Serial.print = 50: 640 1280Since both edge polarities work independently, the issue appears related to runtime switching of ICES1.
I am having trouble getting input capture working correctly when I toggle ICES1 bit inside ISR.
Otherwise input capture working ok.
Goal: Measure Duty of 25khz PWM using Timer1 ICP
Using SimulIDE V1.2.0-RC1 & ATmega328
Possible SimulIDE ATmega328 Timer1 Input Capture issue
The following tests were performed on ICP1 (D8):
With 25khz, 20% Duty applied.
Rising-edge capture only: PASS
Falling-edge capture only: PASS
Serial.print = 0: 0 640
Alternating rising/falling by toggling ICES1 in the capture ISR: FAIL
Expected:
High time varies with duty.
Period remains constant.
Serial.print = 20: 320 640 (or close to)
Actual:
High time is always one complete period.
Measured period becomes two actual periods.
Serial.print = 50: 640 1280
Since both edge polarities work independently, the issue appears related to runtime switching of ICES1.
Uploaded files:
Quote from arcachofo on July 22, 2026, 10:08 pmHi and thanks for the detailed report.
I think that issue is already solved: https://simulide.com/p/forum/topic/the-hcsr04-doesnt-work-with-the-attiny2313/
Hi and thanks for the detailed report.
I think that issue is already solved: https://simulide.com/p/forum/topic/the-hcsr04-doesnt-work-with-the-attiny2313/
