1
\$\begingroup\$

As an embedded software engineer I am familiar with "application-level" (if I may call them) pads configuration, such as; function (GPIO, i2c, etc), direction (input or output), active high or low, its initial value if output pin. Yet, I still don't understand a number of electrical properties that also need to be configured for a pad.

The list is a bit long, but to get more accurate answers I would focus on IB and OB in this thread and I will dedicate other threads for the rest. I would appreciate if I get clarifications to the following points:

1) what are output buffer and input buffer for a pad.

2) what is the effect of enabling/disabling these buffers on pads.

3) Is this configuration recommended or necessary.

4) In which case a pad needs input/output buffer to be enabled

In advance thank you.

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

Have a look at the "typical I/O port" of a mid-range PIC Microcontroller. Yes, this uC is akin to the abacus when compared to something like an FPGA, but the electronic principles are identical.

Typical I/O port

The I/O pin is the physical pin of the IC and connects to the outside world. Everything else is an approximation of standard electronic components modelling what goes in inside.

Let's start with a general purpose output:

The two identical symbols marked P and N are FETs of some form or another. In simple terms, they connect the I/O pin directly to Vdd (HIGH) or Vss (LOW) like a switch - but never both at the same time - when the pin is an output. The symbols to their left are logic gates, as you probably recognise, and to their left again are D-type flip-flops. When you programmatically change an output pin to 1 or 0, a 1 or 0 appears on Data bus, and shortly after WR PORT will go from high to low, triggering the correct output via the flip flops and logic gate. Most uCs handle the WR PORT switching automatically. WR TRIS, in the case of a PIC, determines whether the pin is an input or an output therefore if you try to set an input-pin to a value, the command never makes it to the logic gates because the TRIS Latch flip-flop is locked in the 'off' position.

Going beyond General Purpose, you will always end up with the FET ('P' and 'N') devices as they are what physically provide the high and low signals. They might be controlled directly by a PWM controller, or a UART/SPI/I2C peripheral and you may have no direct access to them in software, but the FETs act as the buffer between inside and outside.

A general purpose input is much easier to describe in its simplest case. The triangle labelled TTL or Schmitt Trigger acts as the buffer; again it isolates the inside and the outside. As the footnote in the diagram mentions, "protection diodes" are included (but not shown) to save the uC being damaged from signals exceeding the range of Vss and Vdd. The output of this initial buffer is fed into another flip flop, such that when the pin is polled, RD PORT triggers the value at the I/O pin to be written onto Data bus.

Going beyond General Purpose, the TTL buffer may be replaced with an analogue buffer for the input to an ADC, or again it might feed to an non-directly acessible UART/SPI/I2C peripheral.

So, to answer your questions...

(1) What are buffers? See above! Ultimately, a buffer replicates it's input on it's output, therefore isolating the sensitive 'inside' from the nasty 'outside'.

(2) What is the effect of enabling/disabling? Usually you can set a pin as an input or an output. If you don't choose yourself, the uC will set it to one or the other by default.

(3) and the rest of (2). It's good practice to set unused pins as outputs, outputting LOW. This stops (a) potentailly wasting power if set to output HIGH, and (b) 'floating' voltages when set to input, which could have odd effects on nearby pins and associated peripherals.

(4) Depending on the hardware, you may have to manually set a pin to input or output even if it can only function as an output (or input). For example, three pins maybe dedicated to and SPI module. I can't guarentee that the pins are hard-wired as the correct type of pins without reading the datasheet for the uC. In the case of PICs it's rare to get a peripheral pin (ADC, I2C, PWM, etc.) that cannot also function as a GPIO. You have to programatticaly set the pin direction before you can use the peripheral properly.

\$\endgroup\$
  • \$\begingroup\$ Just to clarify one point once for all. If I have a pin that can ONLY act as ADC Analog Input which means that its sole function is Input then in this case I don't need to enable input buffer; however if a pin could have multiple functions and could be Input or Output depending on the default configuration of the uC then I should enable either Input or Output buffer to have total control on the pin behavior, right? \$\endgroup\$ – Aymen Jan 27 '15 at 8:10
  • \$\begingroup\$ Unfortunately I cannot vote up your answer as my reputation is still low :(. Yet, I selected it as best answer :) \$\endgroup\$ – Aymen Jan 27 '15 at 8:13
  • \$\begingroup\$ @Aymen yes, if a pin can be an input or an output then you can freely select which it shall be. However, for unidirectional pins that only have one job (like your ADC example) you might still have to explicitly declare it as an input! The same applies of course to explicitly declaring an output-only pin as an output. That sort of thing is specific to the hardware you're using, so you'll have to check the device's data sheet or application notes. For dual purpose pins, such as ADC and GPIO combined, you nay also have to explicitly disable the ADC peripheral if you aren't using it. \$\endgroup\$ – CharlieHanson Jan 27 '15 at 10:22
  • \$\begingroup\$ Thank you for your response. However, I still have two points I hope I get explanation for them if you don't mind. I understood the point you made that unidirectional pins that have one job might need an explicit declaration depending on the hardware I am using. What make this explicit declaration necessary, from hardware perspective, anyway? Also, supposing that datasheet states a need for an explicit declaration, if I don't do that declaration how would the pin behave? \$\endgroup\$ – Aymen Jan 27 '15 at 13:07

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.