2
\$\begingroup\$

I am having this microcontroller - S32K142 64 pin 5V core voltage

I have a few pins which I don't want to use. While checking the datasheet of the Microcontroller, I couldn't find any information regarding 'on what to do with the unused pins'

So, I checked the reference manual of the Microcontroller. Reference Manual

In the reference manual, Section 12.7.1 page 203-204, they have given the below :

enter image description here

My questions :

  1. I couldn't understand what they are saying on 'what to do, If I have an used pin in the Microcontroller'? Can someone tell me what the Reference manual is recommending me to do incase I have some unused pins? Or is there any other place in the reference manual where they mention on what to with the unused pins of the Microcontroller?

  2. I have read a few answers in this site which advice on what to do with the unused Microcontroller pins. For instance, the accepted answer for this question gives a last solution to leave the 'output pins unconnected, but make the pin output'.

My doubt is, like, which configuring a uC pin, we need to specify the all below information, right?

  1. Whether the pin is Input / Output or Both?
  2. Whether it should be High / Low?
  3. Whether Internal Pull-up Enabled or Disabled?
  4. Whether Internal Pull-down Enabled or Disabled?

So, when the last solution of the accepted answer mentioned 'leave unconnected but make the pin output, what are the pin configurations mentioned above 1-4 do we need to follow for the pin? And why? Please explain in simple terms on why does the solution mentions 'A high level is preferred in case you forgot to switch off the internal pull-up resistors' - Does it mention we need to enable the internal pull-up or disable them?

  1. How do you make a pin to be in the high-impedance state? Like should it be Output -High Internal Pull-up enabled? or Output-High Internal Pull-up disabled?

Please help to clarify these doubts

\$\endgroup\$
6
\$\begingroup\$

Setup your unused pins as outputs. You can choose if the output level is selected as high or low.

But if you happen to enable the internal pullup resistor you want to set the output level to a high so that the output driver is not pulling current through the pullup resistor.

Likewise if you happen to enable an internal pulldown resistor (if your MCU supports that) you want to set the output level to a low so that the output driver is not sourcing current to the pulldown resistor.


Some folks prefer to set unused pins to digital mode as inputs and shut off the output driver. In this case you want to enable the pullup resistor (or the pulldown if supported) to ensure that the input is held stable at a high or low level.


Which is preferable? I believe the output mode is preferable because it offers the low impedance of the output driver out at the unconnected pin. When an input mode is used the internal pullup resistors are usually very large values (40K to 150K range is typical) and as such the input impedance is correspondingly high at the unconnected pin which leaves the possibility of that external signal coupling could possibly happen and make the pin appear to toggle or enter the invalid space between the guaranteed high and low logic level thresholds.


Alternative consideration. If you ever want to plan a board design in a way that in the future you may want to use a pin for some work around or to add a new feature using the pin as input but connecting as external pullup resistor is a good strategy. First off you can select a lower resistor value such as 4.7K or 10K to keep impedances down. Secondly the resistor pad offers a very good place to solder re-work wires when you want to prototype that new feature on an existing assembly. This technique is especially valuable when the most modern types of MCU packages are in use with high density SMT pads that are next to impossible to solder a re-work wire to them.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you for the answer. I have a few questions. 1. Could you please let me know what the snapshot of the attached reference manual also recommends regarding the unused pins? 2. When you say "external signal coupling could possibly happen" - could you please tell me how? And 3. Could you please provide an answer to my 3rd question on how to make a pin in high-impedance state? \$\endgroup\$
    – Newbie
    Jun 22 '20 at 7:22
  • 2
    \$\begingroup\$ @Newbie - I answered pretty much everything what to do in my answer although in a generic way that can be applied to any MCU. You as the user of your particular MCU selection can figure out the values from the GPIO configuration registers how to set output, input, pulldowns and/or pullups as per your datasheet. \$\endgroup\$ Jun 22 '20 at 15:01
4
\$\begingroup\$

The worst thing is to enable the digital input buffer, and leave the pin floating. Same applies if it is a tri-stated output.

So you have the following options, which are just different, so they are not in any order of preference.

  1. Leave the IO pin disabled, or set it to analog mode. This will keep input buffer off, so pull up or pull down is not needed. Pin is allowed to float.

  2. Set the pin as digital input. Enable internal pull resistor (up or down), or put an external pull resistor (up or down). But the pin must not float.

  3. Set the pin as push-pull output, so that it's not a tri-stated output. Set it to output low or high.

The chip will disable pull resistors when output driver is active, so it does not matter if you configure pull resistors even when the pin is output.

\$\endgroup\$
7
  • \$\begingroup\$ Thank you for the answer. But can you tell me what the snapshot of the reference manual I have attached, say? I am not clear on what they say. And when you say, leave the IO pin disabled, what should I do? Like should I disable the input or output buffer, or both? And how are you saying that "The chip will disable pull resistors when output driver is active" - is it given somewhere in the datasheet? \$\endgroup\$
    – Newbie
    Jun 22 '20 at 7:18
  • \$\begingroup\$ Could you also mention, how can I make my pin in high-impedance state? \$\endgroup\$
    – Newbie
    Jun 22 '20 at 7:19
  • 1
    \$\begingroup\$ I tried to tell what the snapshot says. What is still unclear? The fact that the chip turns off pull resistors when it is output is written right there in the snapshot, second last sentence. High impedance state means it's not output. High impedance means the pin does not strongly drive to any state (not an output), or does not even weakly drive to any state (pull resistors disabled). So pin can be unconfigured, analog, or digital input, or even tri-stated output, as long as pull resistors are disabled. \$\endgroup\$
    – Justme
    Jun 22 '20 at 7:25
  • \$\begingroup\$ Ok thank you for the answer \$\endgroup\$
    – Newbie
    Jun 22 '20 at 7:32
  • \$\begingroup\$ One question. What if I configure the pin as output low and there is a external pull up? And other question, from what you're saying, no matter what pull configuration I give, when the pin is output, the output driver will ignore the pull configuration? \$\endgroup\$
    – Newbie
    May 21 at 5:28
3
\$\begingroup\$

The big picture here is to not have unconnected pins that are configured as an input. This holds true not only for MCUs but for most devices with a digital input.

Why? Digital inputs have a very high impedance which means they have a very high input resistance which can also be thought of as an antenna that picks up noise. So basically if you leave a digital input unconnected (also called floating), it will behave like a "leave in the wind" and this leads to increased current.

So it is a good practice to enable the internal pull-up or pull-down resistors of the MCU when the pin is configured as an input.

\$\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.