Repository navigation
Conversation
InputCapture and Frequency_Dutycycle_measurement assumed a timer period of 0x10000 ticks when a capture wrapped. Read the period back with getOverflow() and use it in the wrap arithmetic. With a core whose getOverflow() returns uint64_t, a 32-bit timer is set to its full period of 2^32 ticks. With older cores the period stays 0x10000. The high-state duration is kept in 64 bits so that the duty-cycle product does not overflow on 32-bit timers. Refs: stm32duino/Arduino_Core_STM32#2071 Assisted-by: OpenAI Codex: gpt-6.2-sol Assisted-by: Claude Code: claude-opus-5-5 Assisted-by: agentic-hil: https://github.com/agentic-hil/agentic-hil Signed-off-by: Hannes Pauli <mail@hannes-pauli.de>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The two HardwareTimer capture examples hard-code a period of
0x10000ticks in their wrap arithmetic. They now read the configured period
back from the timer and use it.
On a 32-bit timer they request the full period of 2³² ticks when the
core supports it (
getOverflow()returnsuint64_t, stm32duino/Arduino_Core_STM32#3138). With older cores they keep0x10000, so the sketches buildwith both.
Validation
Built with Arduino CLI 1.6.0,
--warnings all, no warnings:PR applied.
(
stm32duino/Arduino_Core_STM323ceb5e2).Run on a NUCLEO-F446RE (90 MHz timer clock). For the test the input pin
was PB10 (TIM2_CH3, 32-bit) instead of
D2, and a TIM3_CH2 PWM on PC7,jumpered to PB10, provided the signal. The measurement code was unchanged.
Evidence for this run (plans, test sketches, the diff to the submitted
examples, job reports and UART logs):
https://github.com/agentic-hil/agentic-hil/tree/d32add7d66d9a8fb056b649ebbe24c0fd29be31c/examples/nucleo-f446re_demo/stm32duino-hardwaretimer-32bit/evidence/examples-bench
Both sketches gave the same values. The core change itself was measured
on the same board. The evidence is public:
https://github.com/agentic-hil/agentic-hil/tree/134403e46078e983a43f3513d022727636d76c95/examples/nucleo-f446re_demo/stm32duino-hardwaretimer-32bit
AI assistance: OpenAI Codex (gpt-6.2-sol) wrote the sketch changes.
Claude Code (claude-opus-5-5) ran the builds and the hardware test
and wrote this text.
I reviewed the diff and the bench results before submitting.
Related
Core PR: stm32duino/Arduino_Core_STM32#3138. Refs stm32duino/Arduino_Core_STM32#2071.