Academic Program

Digital Input Pin Background

Digital Input Pin Background

Typical Digital Pin Structure

Almost every pin on the Enhanced Mid-Range PIC® MCU can be used as a digital input or output pin. 

At Reset:

  • Digital pins revert to input (Hi-Z)
  • Analog-capable pins revert to analog

Five registers control the operation of a digital pin. These 8-bit registers control 8 pins of a PORT. Using the registers TRISX, PORTx, LATx, WPUx, and ANSEL, the program can:

  • Configure a pin as an input or output - TRISx
  • Read an input pin (or all 8 PORT pins) - PORTx
  • Output a 1 or 0 to a pin - LATx
  • Enable or disable the internal Pull-Up Resistor - WPUx
  • Determine if analog capable pins operate in analog or digital mode - ANSEL

basic-digital-io.png

 

Multiplexed Pins

In addition to being configured as digital I/Os, pins on enhanced mid-range PIC® MCUs can have several possible functions. The pin diagram on the datasheet shows the options for each pin. At start-up, the program has the option of configuring the pins.

multiplexed.png