5
\$\begingroup\$

I am taking a microcontroller class in university and have the following problem:

(Sorry for the poor image quality)

enter image description here

Its fairly simple but here is my problem: In my solution I set the internal pullup resistors on the input pins. I realise you don't need to because of the presence of the external pullups but I though it would be safe to do nonetheless. From my perspective, enabling the the internal pullups does not affect the operation of the circuit, however apparently the correct answer is that the internal pullups should be disabled and I'm not sure why. Isn't it a good idea to have the internal pullups enabled for redundancy so in case something happens to the external pullups the input pins still have a defined state?

\$\endgroup\$
  • \$\begingroup\$ Did you write what you just said, in the answer? \$\endgroup\$ – Harry Svensson Apr 23 '18 at 23:33
  • \$\begingroup\$ No because the answer was written in C code so I didn't add huge comments but to me it would seem obvious that it would be okay to enable the internal pullups, especially from the point of view of the professor. \$\endgroup\$ – Andrew Schroeder Apr 23 '18 at 23:35
  • 1
    \$\begingroup\$ I utilized one of unsharp masking filters I programmed for MATLAB to enhance your picture so you can read it better :) hope it works. Just waiting for the admins to approve my edit. \$\endgroup\$ – KingDuken Apr 24 '18 at 0:01
  • \$\begingroup\$ As a little note, the internal pullups are not resistors, they are small fets, connected as current sources. So they are much more constant current than a resistor. Which is actually quite nice - gives a more linear ramp, than exponential curve. \$\endgroup\$ – Henry Crun Apr 24 '18 at 0:11
  • 1
    \$\begingroup\$ @AliChen - you are misreading it. What it actually says is "Only alter bits particular to the purpose described here". That in no way disallows fully configuring the I/Os used, what it bans is full-port writes - the students are required to use bit set/reset functions or bitmasks to leave the unused channels unchanged (as they may be in use for something else). That line of the assignment has no relevance to the dispute between the student and the teacher. \$\endgroup\$ – Chris Stratton Apr 24 '18 at 4:29
6
\$\begingroup\$

I see this as both an assignment-interpretation question as well as an electronics question.

Electronics-wise: The internal pullup will be in parallel with the external one. So if there's an internal 10k pullup plus an external 10k pullup, the actual pullup resistance will be 5k, which may or may not be what you want in general. In practice, in this case it's going to be totally harmless, but that won't always be the case. Your argument that it ensures the pin has a defined state even if the external resistance gets disconnected could be reasonable, or not, depending on how the circuit is physically instantiated.

Assignment-wise: The question specified that you should not disturb any configuration bits not necessary to solve the problem. Since the external pullups are present, altering the internal pullup configuration is not necessary to solve the problem, so you shouldn't do it. My guess is that the assignments are being automatically graded, and the autograder software is not flexible about handling various otherwise-legitimate configuations of control bits, which is why you're being asked to leave them alone.

The (human) grader probably should explain all this and give you full credit this time, while asking you not to do it again; but my suggestion to you is to take this as a lesson, that the grader is inflexible about these things, and do your future assignments accordingly.

\$\endgroup\$
  • \$\begingroup\$ Perfect, thank you for the very clear and helpful reply! \$\endgroup\$ – Andrew Schroeder Apr 23 '18 at 23:57
  • 1
    \$\begingroup\$ All Hail the glorious future of Artificial Intelligence! \$\endgroup\$ – Henry Crun Apr 24 '18 at 0:08
  • \$\begingroup\$ @HenryCrun He failed to rigorously follow the specification. One could argue that setting internal pullups probably didn't violate the "Please ensure ..." & "only alter ..." requirements. But unless you can GUARANTEE that probably =1 in all cases, you fail. Alas. Otherwise, it seems like a good decision oin his part :-). \$\endgroup\$ – Russell McMahon Apr 24 '18 at 1:01
  • \$\begingroup\$ I was merely responding to Glenns "Autograder" comment. I hear the voice of Dredd intoning "He failed to rigorously follow the specification" \$\endgroup\$ – Henry Crun Apr 24 '18 at 1:29
  • \$\begingroup\$ The prohibition on changing other bits has nothing to do with the dispute over the pullups, it's merely a prohibition on changing the configuration of other port channels not being used, ie, bit set/reset or masks must be used. \$\endgroup\$ – Chris Stratton Apr 24 '18 at 4:31
2
\$\begingroup\$

This sounds more like a disagreement in style than an answer that is actually wrong. But if I was being pedantic there are a few small issues I see with having both:

  1. The two resistors are in parallel. This lowers their effective resistance and strengthens their ability to pull the pin up.

  2. The redundant pullups would waste additional current when the pin is pulled low.

I wouldn't consider either of these potential issues to be major issues, but if I would trying to teach you good practice I would probably tell you not to do it.

\$\endgroup\$
  • 1
    \$\begingroup\$ No, (1) it strengthens the pullup, and increases the ability to pull up \$\endgroup\$ – Henry Crun Apr 24 '18 at 0:45
  • 1
    \$\begingroup\$ There is some sense in enabling pullups as matter of course, when you have unused pins, so that you know they are not left floating (which causes idle current drain) \$\endgroup\$ – Henry Crun Apr 24 '18 at 0:56
  • \$\begingroup\$ Brett - no, as Henry says, Ra=ext in parallel with an internal ~= current source acts like a smaller resistor so stronger pullup. \$\endgroup\$ – Russell McMahon Apr 24 '18 at 1:02
  • \$\begingroup\$ +1 for mentioning that enabling the internal pullup wastes current through the IC power pins, and therefore die temperature. However, it really doesn't strengthen the effective pull up when combined with an external resistor as the internal pullup is generally very weak, between 60-120k Ohms, and not very accurate. \$\endgroup\$ – TimB Apr 24 '18 at 3:06
  • \$\begingroup\$ @TimB Does it weaken it? \$\endgroup\$ – Harry Svensson Apr 24 '18 at 5:01
0
\$\begingroup\$

I can see a (minor) problem:

The external pullups go to VCC, but the internal ones might only go to VCC - x (i. e., a lower voltage, due to voltage drops or whatever reason). This might result in a current from the external VCC through the external and internal pullups to the internal voltage supply. Although this current is probably quite low, it can (and maybe should) be avoided.

\$\endgroup\$
  • \$\begingroup\$ There's a specification for this; typically you are allowed to raise an I/O up to just less than a diode drop above the chip's I/O bank supply. Driving one to the relevant I/O bank supply voltage would be quite normal. If there's a limit on current pushed to an internal regulator that should be in the data sheet as well, though internal regulators that supply just the core are more common than those supplying the whole chip including I/Os banks. \$\endgroup\$ – Chris Stratton Apr 24 '18 at 14:02

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.