3
\$\begingroup\$

I am constructing a circuit where 2 microcontrollers will communicate with a high or low state on their IO pin. Basicly a state pin for Bluetooth connected, or not. One microcontroller will have an IO pin as an output and the other an IO pin as an input. I know my microcontroller has an internal pull up (also pull down) resistor, but how does this circuit look like? Below is how I want to connect it, for sure I shouldn't need to have resistors when there are internal ones, right?

schematic

simulate this circuit – Schematic created using CircuitLab

So my real question is how does the internal pull up/down resistors look in the microcontroller? Is it like this?

schematic

simulate this circuit

\$\endgroup\$
  • 2
    \$\begingroup\$ If your output is pulling both high and low i.e. not configured as open drain, you don't need pull-up or pull-down resistors. \$\endgroup\$ – Phil G Apr 15 at 14:54
  • \$\begingroup\$ I'm not sure what you mean here, could you elaborate? \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:00
  • 1
    \$\begingroup\$ Typically the internal pulling resistors are actually FETs. In a few cases wired more as current sources than resistors. Such implementation detail is device specific and seemingly not really relevant to your practical question. \$\endgroup\$ – Chris Stratton Apr 15 at 15:01
  • \$\begingroup\$ What I'm concerned with is of course if I can connect my circuit like in my first schematic and how I would do so as to not damage the components. It seemed to me this was reliant on how the internal "resistors" was connected \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:06
7
\$\begingroup\$

In your example, R1 is a pull-down and R2 is a pull-up resistor. Depending on the MCU and the pin involved there may be one or the other or both or neither available. That information will be in the datasheet. There's also another possibility, a "hold" where there is a resistor internally from a buffer output back to the input.

The purpose of a pull-up or pull-down is to put the input line in a known state if the connection to it is high-impedance. On an MCU that can happen if the wire gets disconnected or if the driver is deliberately tristated or during startup before it is configured. If the line is being driven push-pull it does little but waste power.

Whether a pull-up or pull-down is required is dependent on your requirements. As to whether the internal resistor is sufficient, again that depends on the requirements. The IC makers tend to choose rather high values which may not be desirable in certain circumstances where EMI or leakage is present. There might be cases where the values are too low (very low power systems, for example). The on-chip resistors (or equivalent) also have quite a loose tolerance typically. So there are many cases where a pull-up or pull-down is available on the chip, but the designer chooses to use an external resistor.

\$\endgroup\$
  • \$\begingroup\$ So what I really want to do is read a high and low state but I do have control over both microcontrollers to program the logic, so in that sense I guess pull up/down resistors are not necesarry. Would I be able to supply 3.3v directly to the input of one microcontroller? What I am concerned with it short circuiting it. \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:13
  • \$\begingroup\$ The input should never exceed the supply voltage of the chip. If the two units are powered from the same source, no problem, but otherwise you might need to add a resistor to prevent damage. It's not a bad idea to have a resistor there anyway, in case you have to make changes, at least at early stages. \$\endgroup\$ – Spehro Pefhany Apr 15 at 15:17
  • \$\begingroup\$ Of course, they will both be 3.3V logic from the same source. This cleared up my question, thanks. \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:19
  • \$\begingroup\$ The EMI argument in this specific case should rather be about how much current the driving MCU pin will drive and pull resistors shouldn't be necessary unless there's connectors in between the MCUs. Picking an external pull resistor before an internal one rather refers to cases where there signal isn't always driven to a stable voltage (like when the first MCU is still booting up and has not yet configured its pin to be an output). \$\endgroup\$ – Lundin Apr 15 at 15:24
  • \$\begingroup\$ @Lundin If the pull-up or pull-down is necessary at all, there is a condition or conditions under which the resistor is responsible for asserting the logic state. The EMI during that state is the concern wrt the resistor value. It might be open-drain or during startup or with cable disconnected or something else altogether. \$\endgroup\$ – Spehro Pefhany Apr 15 at 15:27
2
\$\begingroup\$

Pull-ups and pull-downs are usefull for setting the "default" logic level when the input pin may be left unconnected or at a high impedance state. These pull (virtual) resistors can be configured by your code but usually default to being disabled when you do nothing about them.

If you're worried about frying you micro because there are no resistors between the Bluetooth IC output and the micro input to limit current, then don't worry. When set as inputs microcontroller pins have high impedance, which means they draw (almost) no current.

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

The normal way of doing this is to disable the pullups, at both ends, and drive in both directions.

A feature you may want to add if you're worried about damage and not about signal speed is a series resistor between the two microcontrollers. Size this so that the current flowing if one end drives high and the other drives low is limited to a safe value for both. This is usually about 20ma. That suggests a resistor in the 150-200 Ohm range, although for your purpose you could have any value from 150R - 10k without noticing any adverse effects.

\$\endgroup\$
  • \$\begingroup\$ I'm mostly worried about speed but of course I don't want to damage the microcontrollers. They both have 3.3v logic though. When you say drive in both directions, what do you mean by this? Surely one is input and the other output, or are you suggesting them both being configured output and one high, one low? \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:42
  • \$\begingroup\$ No, only one as an output, but driven high or low depending on value. As opposed to the "open drain" configuration, which is driven low but "pulled" high by the resistor. When you say you are worried about speed, how fast do you need the signal to be? \$\endgroup\$ – pjc50 Apr 15 at 15:53
  • \$\begingroup\$ I see. I need the signal to be read in the microsecond range, preferably < 1us. \$\endgroup\$ – Marius Gulbrandsen Apr 15 at 15:57
-1
\$\begingroup\$

Yes. I think you answered the question by your example. But just to be on the safe side- Pull down/up resistors are supposed to determine the logic level at startup. Pull down will always be connected to the lowest logic level (e.g GND in your case) and pull up to the highest logic level (e.g VCC of the micro-controller in your case) So they will be connected internally to the GND/VCC ...

New contributor
Daniel Sapir is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$

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.