{"record":{"id":"72115fd326eac712","repo":"embassy-rs/embassy","slug":"all-pins-must-either-be-32-or-16-in","errorCode":null,"errorMessage":"All pins must either be <32 or >=16, in:{:?}-{:?}, side:{:?}-{:?}, set:{:?}-{:?}, out:{:?}-{:?}, bypass:{:#x}","messagePattern":"All pins must either be <32 or >=16, in:(.+?)-(.+?), side:(.+?)-(.+?), set:(.+?)-(.+?), out:(.+?)-(.+?), bypass:(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-rp/src/pio/mod.rs","lineNumber":872,"sourceCode":"                    low_ok &= pin < 32;\n                    high_ok &= pin >= 16;\n                }\n            }\n            let mut bypass = config.input_sync_bypass_mask;\n            while bypass != 0 {\n                let pin = bypass.trailing_zeros() as u8;\n                low_ok &= pin < 32;\n                high_ok &= pin >= 16;\n                bypass &= bypass - 1;\n            }\n\n            if let Some(jmp_pin) = config.exec.jmp_pin {\n                low_ok &= jmp_pin < 32;\n                high_ok &= jmp_pin >= 16;\n            }\n\n            if (!low_ok && !high_ok) || (!high_ok && gpio_base_latched) {\n                panic!(\n                    \"All pins must either be <32 or >=16, in:{:?}-{:?}, side:{:?}-{:?}, set:{:?}-{:?}, out:{:?}-{:?}, bypass:{:#x}\",\n                    config.pins.in_base,\n                    config.pins.in_base + config.in_count - 1,\n                    config.pins.sideset_base,\n                    config.pins.sideset_base + config.pins.sideset_count - 1,\n                    config.pins.set_base,\n                    config.pins.set_base + config.pins.set_count - 1,\n                    config.pins.out_base,\n                    config.pins.out_base + config.pins.out_count - 1,\n                    config.input_sync_bypass_mask,\n                )\n            }\n            let shift = if low_ok && !gpio_base_latched { 0 } else { 16 };\n\n            if !gpio_base_latched && shift == 16 {\n                // GPIO_Base set for the first time, update all SMs\n                for i in 0..4 {\n                    if i != SM {","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-rp/src/pio/mod.rs#L854-L890","documentation":"When applying a PIO config on RP235x with GPIOBASE routing, all pins referenced by the program (in, side-set, set, out, and the input-sync bypass mask plus jmp pin) must be addressable: either all <32 (base 0) or all >=16 (base 16), and the base must be consistent with any latched gpio_base. If the config mixes banks or conflicts with a latched base, `set_config` panics with this detailed dump.","triggerScenarios":"Calling `StateMachine::set_config` (which latches the config) with a Config whose in/sideset/set/out base ranges or jmp_pin straddle the 16/32 boundary, or whose bypass mask requires a different GPIOBASE than the one already latched.","commonSituations":"RP235x programs that use e.g. in_base 12 with out_base 20; reconfiguring a state machine after the GPIOBASE was latched to the other bank; porting RP2040 code using pins 12..20 to RP235x.","solutions":["Reassign program pin bases so every pin group lies entirely in pins <32 or entirely in pins >=16","If the program genuinely needs pins across the boundary, split the functionality or change wiring","If gpio_base was latched by an earlier set_config, recreate the PIO/SM config or reset so the correct base is applied first","Check the bypass mask in the message: it must fit within the single chosen 32-pin window"],"exampleFix":"// before\nlet mut c = Config::default();\nc.set_set_pins(&[pin_28, pin_30]); // straddles? both >=16 ok, but in pins <16 would fail\n// after\nlet mut c = Config::default();\nc.set_set_pins(&[pin_16, pin_18]); // keep all used pins in one bank (>=16)","handlingStrategy":"validation","validationCode":"fn all_pins_one_bank(bases: &[Option<u8>]) -> bool {\n    let pins: Vec<_> = bases.iter().flatten().copied().collect();\n    pins.iter().all(|&p| p < 32) || pins.iter().all(|&p| p >= 16)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assign all program pin groups (in/side/set/out/jmp) to a single pin bank on RP235x","Avoid re-latching configs with conflicting gpio_base; rebuild the config from scratch","Check the bypass mask fits the chosen bank before set_config"],"tags":["pio","embedded","gpio","config","rust"],"backgroundTag":"conflicting-config-options","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}