Output Compare Peripheral Library Interface for Harmony v2

Detailed descriptions for this library can be found on "MPLAB® Harmony v2 Help and Documentation"
(found in the <harmony install directory>/doc folder).

Interface Header File

The interface to the Output Compare (OC) Peripheral library is defined in the plib_oc.h header file, which is included by the peripheral library header file, peripheral.h. Any C language source (.c) file that uses the Output Compare Peripheral Library must include peripheral.h.

Library File

The Output Compare Peripheral library archive (.a) file is installed with MPLAB® Harmony.

Output Compare Peripheral Library Description

The Output Compare Peripheral Library is used to simplify low-level access to the Output Compare module without having the need to directly interact with the module's registers. The function names are generic and lead to easier access to the Output Compare module on different devices. The figure below shows the output compare module Software Abstraction Block Diagram.

output-compare-software-abstraction.png

Output Compare Library Overview

The library interface routines are divided into various sub-sections, which address one of the blocks or the overall operation of the Output Compare module.

Library Interface Section Description
General Setup Functions Provides setup, configuration and status control interface routines
Compare Mode Functions Provides Compare mode interface routines
Timer Functions Provides Timer interface routines
Power-Saving Modes Functions Provides Power-Saving modes interface routines
Faults Functions Provides Faults interface routines
Feature Existence Functions Provides interface routines that determine whether or not certain features are available

Output Compare Library Interface

General Setup Functions

Function Name Description
PLIB_OC_Disable Disable the OC module
PLIB_OC_Enable Enables the OC module
PLIB_OC_ModeSelect Selects the compare mode for the OC module
PLIB_OC_PolarityInvertedDisable Disables OC module output inversion polarity
PLIB_OC_PolarityInvertedEnable Output compare polarity is inverted

Compare Mode Functions

Function Name Description
PLIB_OC_Buffer16BitSet Sets a 16-bit primary compare value for compare operations
PLIB_OC_Buffer32BitSet Sets a 32-bit primary compare value for compare operations
PLIB_OC_BufferSizeSelect Sets the buffer size and pulse width to 16-bits or 32-bits
PLIB_OC_PulseWidth16BitSet Sets a 16-bit pulse width for OC module output
PLIB_OC_PulseWidth32BitSet Sets a 32-bit pulse width for OC module output
PLIB_OC_PWMDutyCycleResolutionSet Sets the PWM duty cycle resolution and delays the falling edge of OC output in compare modes

Timer Functions

Function Name Description
PLIB_OC_IsTriggered Checks whether or not a timer source has been triggered
PLIB_OC_SyncModeSelect Selects the synchronization mode for the OC module
PLIB_OC_SyncSourceSelect Selects the input source for synchronous or asynchronous (triggered) operation of the OC module
PLIB_OC_TimerSelect Selects a clock source for the OC module
PLIB_OC_TriggerClear Clears the trigger status for the OC module
PLIB_OC_TimerSelect Selects a clock source for the OC module
PLIB_OC_TriggerClear Clears the trigger status for the OC module
PLIB_OC_TriggerSet Sets the trigger status for the OC module
PLIB_OC_TriggerStatusModeSelect Selects the trigger status reset mode
PLIB_OC_AlternateClockDisable Selects Timer 2/3 instead of the alternate clock source
PLIB_OC_AlternateClockEnable Selects the alternate clock source

Power-Saving Modes Functions

Function Name Description
PLIB_OC_StopInIdleDisable OC module continues operating when the device enters Idle mode
PLIB_OC_StopInIdleEnable Discontinues OC module operation when the device enters Idle mode

Faults Functions

Function Name Description
PLIB_OC_FaultHasOccurred Checks if a PWM fault has occurred
PLIB_OC_FaultInputSelect Selects a Fault input for the OC module
PLIB_OC_FaultModeSelect Selects an automatic or software-based mode to clear the Fault
PLIB_OC_FaultOutSelect OC output pin is driven to a known state on a Fault
PLIB_OC_FaultTristateSelect The OC module output can be tri-stated or driven to a known state when a Fault occurs

Feature Existence Functions

Function Name Description
PLIB_OC_ExistsAlternateClock Identifies whether the AlternateClock feature exists on the OC module
PLIB_OC_ExistsBufferSize Identifies whether the BufferSize feature exists on the OC module
PLIB_OC_ExistsBufferValue Identifies whether the BufferValue feature exists on the OC module
PLIB_OC_ExistsCompareModeSelect Identifies whether the CompareModeSelect feature exists on the OC module
PLIB_OC_ExistsEnableControl Identifies whether the EnableControl feature exists on the OC module
PLIB_OC_ExistsFaultInput Identifies whether the FaultInput feature exists on the OC module
PLIB_OC_ExistsFaultModeSelect Identifies whether the FaultModeSelect feature exists on the OC module
PLIB_OC_ExistsFaultOutSelect Identifies whether the FaultOut feature exists on the OC module
PLIB_OC_ExistsFaultStatus Identifies whether the FaultStatus feature exists on the OC module
PLIB_OC_ExistsFaultTristateSelect Identifies whether the FaultTristateSelect feature exists on the OC module
PLIB_OC_ExistsPolarityInvert Identifies whether the PolarityInvert feature exists on the OC module
PLIB_OC_ExistsPulseWidth Identifies whether the PulseWidth feature exists on the OC module
PLIB_OC_ExistsPWMDutyCycleResolutionControl Identifies whether the PWMDutyCycleResolution feature exists on the OC module
PLIB_OC_ExistsStopInIdle Identifies whether the StopInIdle feature exists on the OC module
PLIB_OC_ExistsSyncModeSelect Identifies whether the SyncModeSelect feature exists on the OC module
PLIB_OC_ExistsSyncSourceSelect Identifies whether the SyncSourceSelect feature exists on the OC module
PLIB_OC_ExistsTimerSelect Identifies whether the TimerSelect feature exists on the OC module
PLIB_OC_ExistsTimerTriggered Identifies whether the TimerTriggered feature exists on the OC module
PLIB_OC_ExistsTriggerControl Identifies whether the TriggerControl feature exists on the OC module
PLIB_OC_ExistsTriggerStatusModeSelect Identifies whether the TriggerStatusModeSelect feature exists on the OC module

Data Types and Constants

Function Name Description
OC_16BIT_TIMERS Lists different 16-bit time bases for OC module
OC_BUFFER_SIZE Lists different buffer sizes for compare value
OC_CLOCK_RESOLUTION Lists different PWM resolutions for PWM mode and OC output falling edge delay for compare modes
OC_COMPARE_MODES Lists different compare modes for OC module
OC_FAULT_MODES Lists modes to clear fault mode
OC_FAULT_OUT Provides state of OC output pin when a fault occurs
OC_FAULT_TRISTATE Lists modes to clear fault mode
OC_FAULTS Lists different fault sources for OC module
OC_MODULE_ID This enumeration defines number of modules which are available on the microcontroller. This is the super set of all the possible instances that might be available on Microchip microcontrollers. Refer to the specific device data sheet to get the correct number of modules defined for the desired microcontroller
OC_SYNC_MODES Lists different synchronization modes for OC module
OC_SYNC_SOURCES Lists different synchronization sources for OC module
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.