Skip to content

Reject RP2040 3-PWM pins sharing a compare channel - #590

Draft
misaacastillo wants to merge 1 commit into
simplefoc:devfrom
misaacastillo:fix/rp2040-3pwm-channel-alias
Draft

misaacastillo wants to merge 1 commit into
simplefoc:devfrom
misaacastillo:fix/rp2040-3pwm-channel-alias

Conversation

@misaacastillo

@misaacastillo misaacastillo commented Nov 10, 2026 •

Copy link
Copy Markdown

Description

Fixes #589.

The RP2040 3-PWM configuration now checks the resolved slice and channel
for each phase before allocating driver parameters or configuring GPIO.
Different channels on the same slice remain valid. The check uses the same
pin mapping as PWM setup, including Arduino pin remapping.

Type of change

  • Bug fix

Verification

  • The host reproducer
    demonstrates the failure in the original driver.
  • Host tests on the patched driver reject aliased pins before any hardware
    writes and preserve independent compare values for valid pins. The test
    covers RP2040 and RP2350 builds, with both direct GPIO numbers and remapped
    Arduino pins.
  • Built a minimal BLDCDriver3PWM sketch with PlatformIO and Arduino-Pico
    for Raspberry Pi Pico and Pico 2 W. Physical PWM and motor testing remain
    pending.

Re-run the host regression

Download verify-fix.sh
and run sh verify-fix.sh with a C++17 compiler, curl, and shasum. It fetches
and hash-checks the exact base and head driver revisions. The baseline
accepts the GP0/GP16 alias. The patch rejects conflicts before register
writes and preserves independent duty writes in all four host builds.

The two firmware builds used PlatformIO Raspberry Pi RP2040
1.17.0+sha.22a4cc6, Arduino-Pico 1.50201.0+sha.ded8a8a, and ARM GCC
14.2.0. Host models and successful builds cover the checks above. Physical
PWM verification remains pending.

Prepared with Codex assistance. This draft is open for maintainer feedback.

Check the resolved PWM slice and channel before allocation or configuration. Preserve valid pairs of distinct channels on the same slice. Prepared with Codex and verified with host tests and Pico builds.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant