Skip to content

test/automated: PWM duty cycle verification test using GPIO loopback#3568

Open
wiktorkwiatkowski wants to merge 2 commits intoapache:masterfrom
wiktorkwiatkowski:pwm_app
Open

test/automated: PWM duty cycle verification test using GPIO loopback#3568
wiktorkwiatkowski wants to merge 2 commits intoapache:masterfrom
wiktorkwiatkowski:pwm_app

Conversation

@wiktorkwiatkowski
Copy link
Contributor

@wiktorkwiatkowski wiktorkwiatkowski commented Feb 2, 2026

Add test that verifies PWM duty cycle accuracy by sampling the
output pin via GPIO reads. The test uses a timer to sample GPIO state
and calculates measured duty cycle from high versus total samples.

Each test configures PWM duty, collects samples via timer callback,
and validates measured duty falls within tolerance.

Test requires physical loopback between PWM output and GPIO input pin.

Related to #3566

@sjanc sjanc self-assigned this Feb 16, 2026
@sjanc sjanc self-requested a review February 16, 2026 10:43
Wiktor Kwiatkowski added 2 commits February 18, 2026 15:47
The framework provides macros for defining test cases and test
suites with automatic counting of passed and failed tests.

Features:
- MTEST_CASE macro for defining individual test cases
- MTEST_SUITE macro for grouping test cases into suites
- MTEST_INIT_ASSERT, MTEST_CLEANUP_ASSERT, and MTEST_CASE_ASSERT
  macros for test assertions with formatted output per test phase
- MTEST_INIT and MTEST_CLEANUP for initializing/deinitializing
  necessary resources
- MTEST_RUN_INIT and MTEST_RUN_CLEANUP for executing
  initialization and cleanup

Init and cleanup are optional for the user to define. Any
configuration to be done must be run explicitly by the user
via the defined macros MTEST_RUN_INIT and MTEST_RUN_CLEANUP
at the beginning and end of the suite, test cases should be
placed between those two macros.
Add test that verifies PWM duty cycle accuracy by sampling the
output pin via GPIO reads. The test uses a timer to sample GPIO state
and calculates measured duty cycle from high versus total samples.

Each test configures PWM duty, collects samples via timer callback,
and validates measured duty falls within tolerance.

Test requires physical loopback between PWM output and GPIO input pin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments