1
\$\begingroup\$

I am building a board based around an STM32L051C6 microcontroller, which will measure a hall effect sensor (AH3362Q) and count the time in between the edges the sensor sees. The sensor is powered from 12V, and the MCU is powered by a 3.3V switching regulator (ROF-78E3.3-0.5SMD-R) which is powered from the same 12V. The sensor's output, being open-drain, is connected directly to the GPIO of the MCU, which is configured with internal pull-up.

I powered up the board without the sensor plugged in, and everything (minus the sensor functionality of course) worked fine. Then I powered the board off, connected the sensor, powered it back on, and observed that the chip began to heat up drastically. The chip is now dead, even when the sensor is unplugged.

My question is: what could be causing the MCU to die when the sensor is plugged in, given that its output is open-drain and shouldn't be driving the MCU pin at high voltage? Originally, in STCubeMX, I noticed that the GPIO mode of the timer pin the sensor is connected to was configured to "Alternate function push-pull" rather than the only other option of "Alternate function open drain". However, since the timer is being used in input mode, shouldn't these options should be irrelevant?

edit: Code used to configure GPIO, generated by STM32CubeMX:

GPIO_InitStruct.Pin = MOTOR_SENSE_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; // This was GPIO_MODE_AF_PP in push-pull mode
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM2;
HAL_GPIO_Init(MOTOR_SENSE_GPIO_Port, &GPIO_InitStruct);
\$\endgroup\$

closed as unclear what you're asking by Chris Stratton, RoyC, Edgar Brown, Finbarr, Elliot Alderson Jan 21 at 16:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ Have you measured the voltage on the sensor's output pin when not connected to the MCU, and the voltage/current on the connection when it is connected? \$\endgroup\$ – Nate Strickland Jan 16 at 21:47
  • \$\begingroup\$ Voltage on the output of the sensor is hovering around GND currently as it is in the "triggered" state. I haven't measured anything on the connection when it is connected, I will next time. I wanted to ask this here first before I replace the chip and try again in case there were any other suggestions to try next time. \$\endgroup\$ – Billy Kalfus Jan 16 at 21:49
  • 1
    \$\begingroup\$ Did you observe this failure with a setup containing only the MCU and the sensor, or were they both installed in something more complex, like a vehicle? \$\endgroup\$ – Chris Stratton Jan 16 at 22:07
  • \$\begingroup\$ It is in a more complex system. The MCU is on a board with an LCD, an EEPROM, and an I2C driver (P82B96), which is also powered at 12V. However, all of these things were functioning just fine until I plugged in the sensor. "plugging in the sensor" means just connecting its power pins to the 12V supply and its output pin to the GPIO. \$\endgroup\$ – Billy Kalfus Jan 16 at 22:17
  • 1
    \$\begingroup\$ Most likely the sensor wiring was incorrect and 12v appeared on MCU pin. Double-check that the 12v supply and ground are correctly connected to correct sensor pins. \$\endgroup\$ – Justme Jan 16 at 22:27
1
\$\begingroup\$

If you plugged the sensor in to the +12 and the +12 pin made contact before the ground pin, it's possible the output would be driven to something like +12. Or it could be ESD or miswiring as @Sunny suggests..

In any case, it's extremely bad practice to connect that sort of thing directly to a GPIO. Try adding 10K in series from the pullup (pullup to +3.3, of course) to the GPIO. A small capacitor from the GPIO to ground can be used (maximum value depends on minimum "high" time at the Hall sensor output).

You can't generally use the internal pullup with that configuration, but c'est la vie. Reliable operation takes a few more parts sometimes.

\$\endgroup\$
1
\$\begingroup\$

One problem is that your microcontroller pin is configured as an open-drain output, instead of a high-impedance input. I think the confusion is that the sensor does have an open-drain output, but this is not the setting to use for your input pin.

open drain

In an open-drain configuration, if you set your pin high, the voltage will float up to the voltage on the other side of the pullup resistor. In your case, you are using an internal pullup, so this would be 3.3V.

But, if the pin is low, it will create a short from the pin to ground. Any externally-applied voltage will then burn out your IC (if it isn't current-limited). However, if your only connection to a voltage is via the internal pullup resistor, the current should be well within limits.

Although, as Spehro notes, I'm unsure if the pullup will work when the pin is set to an AF mode.

\$\endgroup\$
-1
\$\begingroup\$

If you followed the sensor schematic with a pullup resistor to Vcc and Vcc was 12V , then that would cause self-destruction. (SCR latchup).

That and otherwise miswired to 12V is the obvious cause.. The only other cause is ESD damage when the cable was connected when powered down.

The HBM model for a finger is 100pF. A cable can be 100pF/ m.

Touching 0V connection on unit before connection is a preventive measure while touching cable conductors.

Interface cables output have 1k to 10k series current limit protection from ESD depending on cable length for low current sensors with a shunt cap to reduce sub-ns rise time of an ESD event.

Less likely causes are an arc welder induced nearby a spike into the sensor cable equivalent to a ESD discharge with open circuit on output.

\$\endgroup\$
  • 1
    \$\begingroup\$ I did not follow that, and specified in my question that I planned to use the internal pullup of the MCU. \$\endgroup\$ – Billy Kalfus Jan 16 at 21:48

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