I'm trying to read some 12V square wave signals from an old car with an STM32. I built some level shifters like shown below to down-shift (and invert) the signal so I can hook it up to an GPIO.


simulate this circuit – Schematic created using CircuitLab

After hooking it up, my STM32 discovery board went black and never returned, so I'm assuming some pin got an overvoltage somewhere and I'm trying to pin it down. Is it possible that my level shifer circuit somehow "leaked" voltage and broke my STM32?

Thanks for any suggestions.

  • 1
    \$\begingroup\$ Circuit looks OK (safe, I mean). Maybe you made a wiring mistake? As a side note, I think 500k is a bit too high for the pullup. But that shouldn't cause your micro to fail. It would just cause the signal rise time to be very long. And 10k is probably too large for the gate as well. \$\endgroup\$ – mkeith Oct 29 '16 at 16:59
  • \$\begingroup\$ Did you connect the ground nets of the car and the STM32? Could the source of the 12 V produce higher voltages in case of load dump or other variation of the car's power voltage? \$\endgroup\$ – The Photon Oct 29 '16 at 17:18
  • \$\begingroup\$ I connected the grounds of STM and car together. I'm starting to assume the error is not in the level shifter circuit. \$\endgroup\$ – Felix S Oct 29 '16 at 17:26
  • 2
    \$\begingroup\$ "12V square wave signals from an old car" - where exactly are these '12V square waves' coming from in the car? \$\endgroup\$ – Bruce Abbott Oct 29 '16 at 18:04

With 500k pullup your Miller coupling is going to be worse. It is proportional to the gain of the inverting amplifier. Even though you are running rail to rail, there is a gain during the transition.

If your input 12V toggled too quickly you could (maybe) couple enough voltage to exceed 3V.

I have attached a simulation showing what I mean. Here, the MOSFET is ideal (no parasitic source-drain capacitance modelled) so I added 10nF to mimic a real MOSFET.


  • 1
    \$\begingroup\$ Interesting possibility. Even worse if he was monitoring the ignition coil terminal. \$\endgroup\$ – KalleMP Oct 29 '16 at 21:02
  • \$\begingroup\$ Is 10n really a realistic value for that capacitor? \$\endgroup\$ – Felix S Oct 30 '16 at 9:49
  • \$\begingroup\$ 10nF is too high for just the intrinsic source-drain capacitance of the BS170. If your wires ran near each other for some distance though, the cap could be increased. 10nF was just chosen to clearly illustrate the phenomenon. \$\endgroup\$ – jbord39 Oct 30 '16 at 13:55

If you got gate and source the wrong way round when you wired it you would put 12V (minus one diode drop of about 0.7 volts) into your GPIO pin. Notice the parasitic diode in the picture below: -

enter image description here

Remember also that not all T092 devices have the same pin out.

It's always sensible in these sorts of experiments to use a current limiting resistor in series with the pin then, if you applied too much voltage at least the current would be limited to a mA or so. That could easily save your STM32.

  • \$\begingroup\$ I checked my wiring and it's ok, possible though that I made something touch while trying it in the car. I don't get it. \$\endgroup\$ – Felix S Oct 29 '16 at 17:25

Did you have low inductive common grounds?, twisted pair? EOS aware of static discharge? and power up 3V before connecting to car 12 V? if not , that could be why. The condition for latchup is >0.7V above Vcc even during power-up. They use dual Schottky diode for protection but an ESD event can be faster than the diodes respond during connection or power up, in some situations, without any feeling of a zap. eg. charged capacitance on cables. for better protection, add an RF cap to input gate and output near sensitive inputs.

Do you need 100 MHz bandwidth? (no)

  • so choose 1000pF or any appropriate value and appraise R values for data rise time // C , this also attenuates cap discharges from say 100pF human finger model by 10:1. Observe signal integrity also from cable capacitance at 50-150 pF/m

A more robust solution is a 10k/3k3 R divider for long cables unless you wanted a logic inverter ... with ground connected first which is what USB connectors do.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.