Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

What must an MCP23S17 sharing chip select receive first on a 16 MHz controller board?

A 16 MHz active oscillator supplies the clock reference on a test controller. With one MCP23S17, expansion I/O reads and writes work. After a second chip is populated, both output groups sometimes change together, or an input read returns the other group's value. The parts share chip select but have distinct address straps. The board provides the address distinction, and the firmware still has to enable it. The first access after an expander reset cannot use the same assumptions as traffic after initialization.

Separate the devices only after enabling hardware addressing

The MCP23017 uses I²C. The MCP23S17 uses SPI, with chip select, clock and separate data directions. The SPI control byte has four fixed upper bits, three address bits and a read/write bit. Once hardware addressing is enabled, the three address bits match the physical straps. With it disabled, the data sheet defines the effective address as all zero. The address pins still need external bias. Software developed for one all-low part can send a convincing first write even if it now reaches both devices sharing CS.

Suppose one device has all address pins low and the second has only A0 high. After reset, use write control byte 0x40 and write 0x08 to register 0x0A in the default register layout. This sets the hardware address enable bit. Both parts accept this startup write. Keep it as a single-register write so the same frame does not change other register settings. On a running board with an unknown register layout or other configuration bits already set, use the known state or an explicit reset. This example is not an arbitrary-state recovery command.

The subsequent read control bytes are 0x41 and 0x43. The write control bytes are 0x40 and 0x42. These are complete SPI control bytes. Do not shift them like seven-bit addresses passed to an I²C API. Reading back the enable bit alone cannot distinguish the devices, since both results should match. Provide two distinguishable external logic levels, read each port and repeat after exchanging the levels. If a board with only one part reads cleanly and the dual-populated version does not, review its startup reads too.

Calculate transaction duration independently from address selection

Suppose the serial peripheral actually divides a 16 MHz active oscillator by four and runs at 4 MHz. A single-register write contains control, address and one data byte. Twenty-four clocks occupy 6 µs. A one-byte read also takes twenty-four clocks, and the return byte occupies the last eight. Two reads account for 12 µs of clock periods before CS setup, hold, idle and software overhead. Increasing the reference cannot replace the initialization write. If polling needs to run faster, check the detailed serial timing under the actual supply conditions.

Capture the command and return paths with the logic analyzer, including the number of clocks under CS. Compare the control byte, the returned byte and the logged result. If hardware addressing is disabled and a read is sent to address zero, both devices can drive the return line. Where they send the same bit, the analyzer can still show a normal logic level. Compare the analog levels and edges when they might disagree. Repeated zeros do not establish that the line is uncontended. The startup configuration write does not require reading the return bus. Begin individual verification with separate reads after hardware addressing has been enabled.

Record the A2 strap and revision on older boards

The manufacturer has a revision A erratum for the top address input. If A2 is high before hardware addressing is enabled, the device requires the control byte's A2 bit to be high. The lower address bits do not matter for that exception. With both A2 straps low, as in the example, verify the normal zero-address initialization. If an older unit has A2 high and the affected revision, one zero-address write cannot be assumed to reach every part. Record the actual silicon revision and straps. Separate chip selects or physical isolation can establish which device accepts each startup command.

If one expander can reset independently, test the recovery interval for address conflict. Suppose the all-zero-address device remains active and the other device has just reset. Until hardware addressing is enabled again, both can decode a zero-address read. Keep the outputs in safe default states in the fixture, complete the verified configuration writes first, and then resume port reads. If the application must access one device while the other boots and cannot ensure their configuration state, separate chip selects isolate the target and its reply. Review that electrical choice before adding another expansion slot.

Test cold boot, controller-only reset and expander-only reset separately. An expander may retain address enable when only the controller resets. Resetting the expanders restores their default addressing. Code that treats both cases alike can appear intermittent. Retain the physical CS capture, the initialization write, both individual reads and the external input values. A substitute 16 MHz active oscillator still requires checking voltage levels, actual SCK and edges. For ports that respond together before address enable, the initialization order is the first correction.

References

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.