I tried looking for an answer for several days, but didn't have any success, so I thought I would ask here. I apologize in advance if this was already answered, and that I was not able to find it in this stack exchange.
I'm trying to use a SP3T switch to connect GND to 2 GPIO of a MCU, from which I will then try to ready LOW (the MCU would setup the pin in read mode, with a pullup resistor), to determine in which "mode" the device is in / would boot into (Normal or Configuration).
I also want to piggy back on these position selection on the switch to connect the MCU to GND to complete the circuit and power the MCU (already connected to Vcc).
To summarize :
- 1 position connected to GPIO and GND on the MCU (Normal mode - MCU powered on)
- 1 position connected to nothing (No mode - MCU powered off)
- 1 position connected to another GPIO and GND on the MCU (Config mode - MCU powered on)
If I connect wires without any other component, both GPIO end up connected to GND, making the MCU think it's in both modes (which is wrong and unwanted) :
So this version doesn't work, I tried to come up with something else based on transistor, and then P-channel MOSFET (only because the project will be powered by a battery, and I wanted to avoid unnecessary power loss with the resistor on the transistor's base, which is avoided with MOSFET if I read correctly) with the following design :
with now the wires connected to the GPIO driving the gate of their corresponding MOSFET, it should allow the MCU's ground pin to then be connected to GND, completing the circuit.
Is this design correct or am I making a mistake somewhere? Maybe there's another way? a simpler way? I'm a bit out of my depth here so any recommendation or advice would be appreciated.
Normal or Configuration
only requires a SPST switch connected to one data pin ... a movable jumper would also work \$\endgroup\$