I wish this post had existed before, so I didn’t have to spend hours trying to debug. Posting it for anyone in the future.
The problem:
When using the Muon's built-in MCP23S17 IO expander (or any device on the primary SPI bus), pins D9 and D10 cannot be used as GPIO. They remain stuck at ~0.7V instead of outputting proper HIGH (3.3V) or LOW (0V) voltages.
Symptoms:
-
digitalWrite(D9, HIGH)results in ~0.7V instead of 3.3V -
Pin appears to be floating/tri-state
-
Issue persists across firmware reflashes (only power cycle fixes it)
-
Occurs on all Muon boards tested (not board-specific)
Root cause: RTL8721DM Pin Multiplexing Constraint. This is not a software bug. It's a hardware design constraint of the RTL8721DM chip.
Technical Explanation
The RTL8721DM has two SPI peripherals with the following pin mappings:
Primary SPI (used by Muon's built-in MCP23S17):
-
D11 = SPI_MISO
-
D12 = SPI_MOSI
-
D13 = SPI_SCK
-
D8 = SPI_SS (MCP23S17 chip select)
SPI1 Primary Pins:
-
D3 = SPI1_MISO
-
D2 = SPI1_MOSI
-
D4 = SPI1_SCK
SPI1 Alternate Pins (THE PROBLEM):
-
D9 = SPI1_MOSI (alternate)
-
D10 = SPI1_MISO (alternate)
When the primary SPI is active (e.g., communicating with the MCP23S17), the RTL8721DM's pin multiplexing hardware reserves the SPI1 alternate pins (D9/D10) at the silicon level. This appears to be a design decision by Realtek to allow fast switching between SPI1 pin configurations, but it creates an undocumented constraint for users.
The SPI1 primary pins are fundamentally incompatible with using the MCP23S17 You must use different pins.