Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Is following statement correct: "the spi master doesn't need to switch between the…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    Is following statement correct:

    "the spi master doesn't need to switch between the multiple slaves because we never write data to the ICs, we just read the ADC values "

  2. Assistant

    Not quite – even if you’re only “reading” ADC data, SPI is still a full-duplex, master-driven bus and you must select the right slave each time you talk to it. Here’s why:

    1. SPI Chip-Select (CS) Still Matters
      • CS tells each ADC “Hey, I’m talking to you now.”
      • When CS is HIGH (inactive), most ADCs tri-state their MISO pin so they don’t clash on the bus.
      • If you leave CS low on all devices, you’ll get bus contention (multiple outputs driving MISO at once).

    2. “Reading” = Sending Clocks + (Dummy) Writes
      • The master always generates the clock pulses.
      • To get N bits back from the ADC, you shift out N “dummy” bits (e.g. 0x00) on MOSI.
      • The ADC clocks its conversion result out on MISO only while its CS is asserted.

    3. What “Switching” CS Means
      – Before each conversion/read:
      a) Pull that ADC’s CS low
      b) Clock out your dummy bytes and clock in the ADC’s result
      c) Pull CS high again
      – Then repeat for the next ADC on its own CS line.

    Exceptions

    • If you’ve got a daisy-chainable ADC that is designed to pass data from one chip to the next, they often share a single CS.
    • If you really tie multiple CS lines low all the time (not recommended), you risk bus contention unless all devices guarantee to tri-state MISO when idle—which most do not for continuous-conversion ADCs.

    Bottom‐Line
    You do need to “switch” (i.e. toggle) the chip-select lines for each slave, even when you’re only doing reads. Otherwise multiple ADCs will all try to drive MISO at once or ignore your clock pulses entirely.

  3. User

    Is it possible to have a same chip select for lets say 7 spi adcs, and then use mux to select between which line of slave outtput connects to the master data in using a mux select?

  4. Assistant

    You can—mechanically speaking—tie all seven ADCs’ CS pins together and then use a fast MUX in front of the MISO bus to “pick” which ADC actually talks back to the master. In effect you’ve moved your slave‐selection from the CS lines onto a separate MUX select bus.

    Here’s what it looks like in block form:

        MCU  ──────┐─────────── SCLK ────────────────────┐
                   │                                      │
                   │                                      │
                   │       ┌──────┐   ┌──────┐           │
                 MOSI      │ ADC1 │   │ ADC2 │  ...      │
                   │       └──────┘   └──────┘           │
                   └──> CS ─┬────────────┬────────────┬──┘
                             │            │            │
                             ▼  ▼  … ▼     ▼            ▼
                           ┌──────────┬──────────┬──────────┐
      All MISO pins ─────> │ MUX (e.g. │ MUX,     │  MUX     │──> MCU MISO
      into               │ 74HC4051 or│ SN74ALVC1│ SN74ALVC1│
      one 8‐to–1 MUX      │ 4066, etc.)│           │          │
                           └──────────┴──────────┴──────────┘
                              ▲    ▲           ▲
                              │    │           │
                             S0   S1  …      S2   ← select lines
    

    – MCU drives one single CS
    – MCU clocks SCLK/MOSI to all ADCs in lock‐step
    – The analog/digital MUX gates only one ADC’s MISO out onto the MCU’s MISO pin

    Pros
    • You really only toggle one CS line
    • All ADCs “see” the same clock frame, so conversions happen in parallel (if they’re free‐running)

    Cons and Cautions

    1. Bus contention if your ADC doesn’t tristate MISO when idle
      – Many SAR ADCs only drive MISO when CS=LOW and they’re clocking data out. But that’s not universal. If two devices ever drive MISO at the same time you’ll get garbled data (and possibly damage).
    2. Speed/edge‐rate degradation
      – A 74HC4051/4066 analog switch or a CMOS MUX adds ~20 – 40 ns of delay and some capacitance. If you’re running SPI at >10 MHz you may need a faster digital mux (for example SN74ALVC1T45, TXB0108, etc.).
    3. Extra GPIOs
      – You’ve just traded 7 CS lines for 3 (S0,S1,S2) select lines (plus 1 common CS), so you’re down from 7→4 pins. You still need address lines!

    Alternatives
    – Use a 3→8 decoder (74HC138) to drive 7 separate CS lines from 3 address pins (+ 1 enable). Now you have 3+1=4 pins, but no analog/digital MUX on MISO.
    – Pick daisy-chainable ADCs (e.g. some ∆∑ parts) so that MISO of ADC1 feeds into MOSI of ADC2 … MOSI of ADC7 → back to master with one CS.
    – Use an I²C-GPIO expander or a shift-register (e.g. 74HC595) to create as many chip-selects as you need from just a few MCU pins.

    Bottom line
    Yes, you can share CS and “steer” MISO with an 8-to-1 MUX, but you must be absolutely sure that only one ADC output is ever connected to the bus at a time (and that the others really are high-Z), and that your MUX can handle your SPI data rates. In most designs it’s simpler—and more robust—to decode your CS lines or choose a daisy-chain‐capable ADC.

  5. User

    Quoting this line: "but you must be absolutely sure that only one ADC output is ever connected to the bus at a time (and that the others really are high-Z), and that your MUX can handle your SPI data rates."

    First of all, when passing through mux the output of slave adcs, in what scenario two adcs output would drive the master input at the same time. I don't see such a possibilty here. Second, how to make sure that mux handles data rates? I mean, it is just a switch, what to look far here?

  6. Assistant

    Here’s some more detail on both points…

    1. “How could two ADCs ever drive MISO at once, if you’re using a MUX?”
      • A good MUX should isolate the un-selected channels, but not all switches guarantee a hard “break-before-make.”
      – During a select-line transition you can get a tiny overlap where both A and B are momentarily on.
      – If both ADCs are actively driving MISO (i.e. none of them truly went high-Z yet), you’ll see bus contention in that window.
      • If you ever switch the MUX before you pull CS high on the old ADC, that ADC’s output could still be driving when the new one comes on-line.
      • Finally, some SAR/Σ-Δ parts don’t tristate MISO simply because CS=HIGH—they need an internal clock-gate or power-down. If yours doesn’t go high-Z when idle, it’ll drive through the MUX even when “deselected.”

      → Best practice:

      1. De-assert (HIGH) the common CS
      2. Wait a few ns (or the t_busy spec of your ADC)
      3. Change the MUX select
      4. Assert (LOW) CS and clock in your data
    2. “What specs matter when choosing a MUX for SPI?”
      At high speeds a FET-based switch isn’t “invisible”—it has resistance, capacitance and propagation delays. Look at:
      • RON (on-resistance)
      – Higher RON + bus capacitance = low-pass filter. Limits f_3dB.
      • CON and COFF (channel capacitance when on/off)
      – Affects edge slew-rate and can add ghost-coupling from one channel to another.
      • Bandwidth or f3dB
      – The MUX datasheet should list an analog bandwidth (e.g. >100 MHz for a 10–20 MHz SPI bus).
      • tON/tOFF (turn-on/turn-off propagation delays)
      – If these are comparable to your bit-period, you’ll get bit-jitter or duty-distortion during the transition.
      • Charge injection or feed-through
      – Can inject glitches when you switch, again potentially corrupting the first few bits after a channel change.

      → Rule of thumb: pick a switch whose analog bandwidth is at least 3× your highest SPI clock and whose turn-on/off specs are a small fraction of one bit time. If you’re in the 10–50 MHz SPI realm, look at “video-grade” analog multiplexers (e.g. ADG or high-speed TI parts) rather than generic 74HC4051.

    — Hope that helps clarify the “hidden gotchas” of steering MISO through a MUX!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.