3.4.17 I/O Pin Controller (PORT)

The IO Pin Controller (PORT) controls the I/O pins of the device. The I/O pins are organized in a series of groups, collectively referred to as a PORT group. Each PORT group can have up to 32 pins that can be configured and controlled individually or as a group.

Using The Library

PORT PLIB provides two kinds of functions which can be used to control PORT Pins:

  • Pin Functions

  • Group Functions

Pin functions take a particular pin as input and operates only on that pin without affecting any other pins. Whereas group functions can operate on multiple pins of the same port together.

Library Interface

peripheral library provides the following interfaces:

Functions

NameDescription
PORT_InitializeInitializes the PORT Library
PORT_PinWriteWrites the specified value to the selected pin
PORT_PinReadRead the selected pin value
PORT_PinLatchReadRead the value driven on the selected pin
PORT_PinToggleToggles the selected pin
PORT_PinSetSets the selected pin
PORT_PinClearClears the selected pin
PORT_PinInputEnableConfigures the selected IO pin as input
PORT_PinOutputEnableEnables selected IO pin as output
PORT_GroupReadRead all the I/O pins in the specified port group
PORT_GroupLatchReadRead the data driven on all the I/O pins of the selected port group
PORT_GroupWriteWrite value on the masked pins of the selected port group
PORT_GroupSetSet the selected IO pins of a group
PORT_GroupClearClears the selected IO pins of a group
PORT_GroupToggleToggles the selected IO pins of a group
PORT_GroupInputEnableConfigures the selected IO pins of a group as input
PORT_GroupOutputEnableConfigures the selected IO pins of a group as output
PORT_PinPeripheralFunctionConfigConfigures the peripheral function on the selected port pin
PORT_PinGPIOConfigConfigures the selected pin as GPIO

Data types and constants

NameTypeDescription
PORT_GROUPEnumIdentifies the port groups available on the device
PORT_PINEnumIdentifies the available Ports pins