CMSIS-Driver_PIC32CZ-CA70  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
AFEC Interface

Driver API for AFEC (plib_afec0.h) More...

Data Structures

struct  AFEC_CALLBACK_OBJECT
 AFEC callback object structure (Harmony compatible). More...
 

Typedefs

typedef uint32_t AFEC_CHANNEL_NUM
 AFEC channel number selection.
 
typedef uint32_t AFEC_CHANNEL_MASK
 AFEC channel mask for enabling/disabling multiple channels.
 
typedef uint32_t AFEC_CHANNEL_GAIN
 AFEC channel gain selection.
 
typedef uint32_t AFEC_INTERRUPT_MASK
 AFEC interrupt mask for enabling/disabling interrupts.
 
typedef uint32_t AFEC_COMPARATOR_MODE
 AFEC comparator mode selection.
 
typedef uint32_t AFEC_TRIGGER_SOURCE
 AFEC trigger source selection.
 
typedef uint32_t AFEC_RESOLUTION
 AFEC resolution selection.
 
typedef uint32_t AFEC_STARTUP_TIME
 AFEC startup time selection.
 
typedef uint32_t AFEC_SIGN_MODE
 AFEC sign mode selection.
 
typedef uint32_t AFEC_TEMP_CMP_MODE
 AFEC temperature comparison mode selection.
 
typedef void(* AFEC_CALLBACK_HANDLER) (uint32_t status)
 Simple AFEC interrupt callback handler type.
 
typedef void(* AFEC_CALLBACK) (uint32_t status, uintptr_t context)
 AFEC interrupt callback type with context (Harmony compatible).
 

Functions

void AFEC0_SoftwareReset (void)
 Software reset of AFEC0.
 
void AFEC0_SetPrescaler (uint8_t prescaler)
 Sets the AFEC0 clock prescaler.
 
void AFEC0_SetStartupTime (AFEC_STARTUP_TIME startup)
 Sets the AFEC0 startup time.
 
void AFEC0_SetTransferPeriod (uint8_t transfer)
 Sets the AFEC0 transfer period.
 
void AFEC0_SetFreeRunMode (bool enable)
 Enables or disables free run mode.
 
void AFEC0_SetSleepMode (bool enable)
 Enables or disables sleep mode.
 
void AFEC0_SetFastWakeup (bool enable)
 Enables or disables fast wakeup mode.
 
void AFEC0_SetTriggerEnable (bool enable)
 Enables hardware trigger.
 
void AFEC0_SetTriggerSource (AFEC_TRIGGER_SOURCE trigger)
 Sets the hardware trigger source.
 
void AFEC0_SetUserSequenceMode (bool enable)
 Enables or disables user sequence mode.
 
void AFEC0_SetResolution (AFEC_RESOLUTION resolution)
 Sets the AFEC0 resolution.
 
void AFEC0_SetSignMode (AFEC_SIGN_MODE signmode)
 Sets the AFEC0 sign mode.
 
void AFEC0_SetTagMode (bool enable)
 Enables or disables TAG mode.
 
void AFEC0_SetSingleTriggerMode (bool enable)
 Enables or disables single trigger mode.
 
void AFEC0_ChannelsEnable (AFEC_CHANNEL_MASK channelsMask)
 Enables AFEC0 channels.
 
void AFEC0_ChannelsDisable (AFEC_CHANNEL_MASK channelsMask)
 Disables AFEC0 channels.
 
void AFEC0_ChannelsInterruptEnable (AFEC_INTERRUPT_MASK channelsInterruptMask)
 Enables channel end of conversion interrupts.
 
void AFEC0_ChannelsInterruptDisable (AFEC_INTERRUPT_MASK channelsInterruptMask)
 Disables channel end of conversion interrupts.
 
uint32_t AFEC0_ChannelsStatusGet (void)
 Gets the channel status.
 
void AFEC0_ConversionStart (void)
 Starts an AFEC0 conversion.
 
bool AFEC0_ChannelResultIsReady (AFEC_CHANNEL_NUM channel)
 Checks if channel result is ready.
 
uint16_t AFEC0_ChannelResultGet (AFEC_CHANNEL_NUM channel)
 Gets the conversion result for a channel.
 
uint16_t AFEC0_LastConvertedDataGet (void)
 Gets the last converted data.
 
uint8_t AFEC0_LastConvertedChannelGet (void)
 Gets the channel number from last converted data.
 
void AFEC0_ConversionSequenceSet (const AFEC_CHANNEL_NUM *channelList, uint8_t numChannel)
 Configures the user-defined conversion sequence.
 
void AFEC0_ChannelGainSet (AFEC_CHANNEL_NUM channel, AFEC_CHANNEL_GAIN gain)
 Sets the channel gain.
 
void AFEC0_ChannelOffsetSet (AFEC_CHANNEL_NUM channel, uint16_t offset)
 Sets the channel offset.
 
void AFEC0_ChannelDifferentialModeSet (AFEC_CHANNEL_NUM channel, bool enable)
 Sets a channel to differential mode.
 
void AFEC0_ChannelDualSampleHoldSet (AFEC_CHANNEL_NUM channel, bool enable)
 Sets a channel to dual sample-and-hold mode.
 
void AFEC0_PGA0Enable (bool enable)
 Enables PGA0.
 
void AFEC0_PGA1Enable (bool enable)
 Enables PGA1.
 
void AFEC0_SetBiasCurrentControl (uint8_t ibctl)
 Sets the AFE bias current control.
 
void AFEC0_ComparatorChannelSet (AFEC_CHANNEL_NUM channel)
 Sets the comparator channel.
 
void AFEC0_CompareAllChannelsEnable (void)
 Enables comparison on all channels.
 
void AFEC0_CompareAllChannelsDisable (void)
 Disables comparison on all channels.
 
void AFEC0_ComparatorModeSet (AFEC_COMPARATOR_MODE cmpMode)
 Sets the comparator mode.
 
void AFEC0_ComparatorFilterSet (uint8_t filter)
 Sets the comparison filter.
 
void AFEC0_CompareWindowSet (uint16_t lowThreshold, uint16_t highThreshold)
 Configures the comparison window.
 
bool AFEC0_ComparatorStatusGet (void)
 Gets the comparator status.
 
void AFEC0_TemperatureRTCTriggerEnable (bool enable)
 Enables temperature sensor RTC trigger.
 
void AFEC0_TemperatureComparisonModeSet (AFEC_TEMP_CMP_MODE cmpMode)
 Sets the temperature comparison mode.
 
void AFEC0_TemperatureCompareWindowSet (uint16_t lowThreshold, uint16_t highThreshold)
 Sets the temperature comparison window.
 
void AFEC0_ChannelErrorCorrectionEnable (AFEC_CHANNEL_NUM channel, bool enable)
 Enables error correction for a channel.
 
void AFEC0_CorrectionSelectSet (uint8_t shUnit)
 Selects the sample-and-hold unit for correction.
 
void AFEC0_CorrectionValuesSet (int16_t offsetCorr, uint16_t gainCorr)
 Sets the correction values.
 
void AFEC0_InterruptsEnable (AFEC_INTERRUPT_MASK interruptMask)
 Enables AFEC0 interrupts.
 
void AFEC0_InterruptsDisable (AFEC_INTERRUPT_MASK interruptMask)
 Disables AFEC0 interrupts.
 
uint32_t AFEC0_InterruptsMaskGet (void)
 Gets the interrupt mask.
 
uint32_t AFEC0_StatusGet (void)
 Gets the interrupt status.
 
uint32_t AFEC0_OverrunStatusGet (void)
 Gets the overrun status.
 
void AFEC0_WriteProtectionEnable (bool enable)
 Enables write protection.
 
uint32_t AFEC0_WriteProtectionStatusGet (void)
 Gets write protection violation status.
 
void AFEC0_SetCallbackHandler (AFEC_CALLBACK_HANDLER callback)
 Registers a callback handler.
 
void AFEC0_CallbackRegister (AFEC_CALLBACK callback, uintptr_t context)
 Registers a callback with context (Harmony compatible).
 

AFEC Channel Number Definitions

Channel number values for use with AFEC_CHANNEL_NUM type.

#define AFEC_CH0   (0U)
 AFEC Channel 0.
 
#define AFEC_CH1   (1U)
 AFEC Channel 1.
 
#define AFEC_CH2   (2U)
 AFEC Channel 2.
 
#define AFEC_CH3   (3U)
 AFEC Channel 3.
 
#define AFEC_CH4   (4U)
 AFEC Channel 4.
 
#define AFEC_CH5   (5U)
 AFEC Channel 5.
 
#define AFEC_CH6   (6U)
 AFEC Channel 6.
 
#define AFEC_CH7   (7U)
 AFEC Channel 7.
 
#define AFEC_CH8   (8U)
 AFEC Channel 8.
 
#define AFEC_CH9   (9U)
 AFEC Channel 9.
 
#define AFEC_CH10   (10U)
 AFEC Channel 10.
 
#define AFEC_CH11   (11U)
 AFEC Channel 11.
 

AFEC Channel Mask Definitions

Channel mask values for use with AFEC_CHANNEL_MASK type.

#define AFEC_CH0_MASK   (1U << 0U)
 AFEC Channel 0 mask.
 
#define AFEC_CH1_MASK   (1U << 1U)
 AFEC Channel 1 mask.
 
#define AFEC_CH2_MASK   (1U << 2U)
 AFEC Channel 2 mask.
 
#define AFEC_CH3_MASK   (1U << 3U)
 AFEC Channel 3 mask.
 
#define AFEC_CH4_MASK   (1U << 4U)
 AFEC Channel 4 mask.
 
#define AFEC_CH5_MASK   (1U << 5U)
 AFEC Channel 5 mask.
 
#define AFEC_CH6_MASK   (1U << 6U)
 AFEC Channel 6 mask.
 
#define AFEC_CH7_MASK   (1U << 7U)
 AFEC Channel 7 mask.
 
#define AFEC_CH8_MASK   (1U << 8U)
 AFEC Channel 8 mask.
 
#define AFEC_CH9_MASK   (1U << 9U)
 AFEC Channel 9 mask.
 
#define AFEC_CH10_MASK   (1U << 10U)
 AFEC Channel 10 mask.
 
#define AFEC_CH11_MASK   (1U << 11U)
 AFEC Channel 11 mask.
 

AFEC Gain Definitions

Gain values for use with AFEC_CHANNEL_GAIN type.

#define AFEC_GAIN_X1   (0U)
 Gain x1 (no amplification)
 
#define AFEC_GAIN_X2   (1U)
 Gain x2.
 
#define AFEC_GAIN_X4   (3U)
 Gain x4.
 

AFEC Interrupt Mask Definitions

Interrupt mask values for use with AFEC_INTERRUPT_MASK type.

#define AFEC_INTERRUPT_EOC0_MASK   (1U << 0U)
 End of Conversion Channel 0 interrupt mask.
 
#define AFEC_INTERRUPT_EOC1_MASK   (1U << 1U)
 End of Conversion Channel 1 interrupt mask.
 
#define AFEC_INTERRUPT_EOC2_MASK   (1U << 2U)
 End of Conversion Channel 2 interrupt mask.
 
#define AFEC_INTERRUPT_EOC3_MASK   (1U << 3U)
 End of Conversion Channel 3 interrupt mask.
 
#define AFEC_INTERRUPT_EOC4_MASK   (1U << 4U)
 End of Conversion Channel 4 interrupt mask.
 
#define AFEC_INTERRUPT_EOC5_MASK   (1U << 5U)
 End of Conversion Channel 5 interrupt mask.
 
#define AFEC_INTERRUPT_EOC6_MASK   (1U << 6U)
 End of Conversion Channel 6 interrupt mask.
 
#define AFEC_INTERRUPT_EOC7_MASK   (1U << 7U)
 End of Conversion Channel 7 interrupt mask.
 
#define AFEC_INTERRUPT_EOC8_MASK   (1U << 8U)
 End of Conversion Channel 8 interrupt mask.
 
#define AFEC_INTERRUPT_EOC9_MASK   (1U << 9U)
 End of Conversion Channel 9 interrupt mask.
 
#define AFEC_INTERRUPT_EOC10_MASK   (1U << 10U)
 End of Conversion Channel 10 interrupt mask.
 
#define AFEC_INTERRUPT_EOC11_MASK   (1U << 11U)
 End of Conversion Channel 11 interrupt mask.
 
#define AFEC_INTERRUPT_DRDY_MASK   (1U << 24U)
 Data Ready interrupt mask.
 
#define AFEC_INTERRUPT_GOVRE_MASK   (1U << 25U)
 General Overrun Error interrupt mask.
 
#define AFEC_INTERRUPT_COMPE_MASK   (1U << 26U)
 Comparison Event interrupt mask.
 
#define AFEC_INTERRUPT_TEMPCHG_MASK   (1U << 30U)
 Temperature Change interrupt mask.
 

AFEC Comparator Mode Definitions

Comparator mode values for use with AFEC_COMPARATOR_MODE type.

#define AFEC_COMPARATOR_MODE_LOW   (0U)
 Event when conversion is lower than low threshold.
 
#define AFEC_COMPARATOR_MODE_HIGH   (1U)
 Event when conversion is higher than high threshold.
 
#define AFEC_COMPARATOR_MODE_IN   (2U)
 Event when conversion is within the comparison window.
 
#define AFEC_COMPARATOR_MODE_OUT   (3U)
 Event when conversion is outside the comparison window.
 

AFEC Trigger Source Definitions

Trigger source values for use with AFEC_TRIGGER_SOURCE type.

#define AFEC_TRIGGER_ADTRG   (0U)
 External trigger (ADTRG pin)
 
#define AFEC_TRIGGER_TIOA0   (1U)
 Timer Counter Channel 0 Output A.
 
#define AFEC_TRIGGER_TIOA1   (2U)
 Timer Counter Channel 1 Output A.
 
#define AFEC_TRIGGER_TIOA2   (3U)
 Timer Counter Channel 2 Output A.
 
#define AFEC_TRIGGER_PWM_EVENT0   (4U)
 PWM Event Line 0.
 
#define AFEC_TRIGGER_PWM_EVENT1   (5U)
 PWM Event Line 1.
 
#define AFEC_TRIGGER_ANALOG_COMP   (6U)
 Analog Comparator.
 

AFEC Resolution Definitions

Resolution values for use with AFEC_RESOLUTION type.

#define AFEC_RESOLUTION_12BIT   (0U)
 12-bit resolution, no averaging
 
#define AFEC_RESOLUTION_13BIT_OSR4   (2U)
 13-bit resolution with 4x oversampling
 
#define AFEC_RESOLUTION_14BIT_OSR16   (3U)
 14-bit resolution with 16x oversampling
 
#define AFEC_RESOLUTION_15BIT_OSR64   (4U)
 15-bit resolution with 64x oversampling
 
#define AFEC_RESOLUTION_16BIT_OSR256   (5U)
 16-bit resolution with 256x oversampling
 

AFEC Startup Time Definitions

Startup time values for use with AFEC_STARTUP_TIME type (in AFE clock periods).

#define AFEC_STARTUP_SUT0   (0U)
 0 AFE clock periods
 
#define AFEC_STARTUP_SUT8   (1U)
 8 AFE clock periods
 
#define AFEC_STARTUP_SUT16   (2U)
 16 AFE clock periods
 
#define AFEC_STARTUP_SUT24   (3U)
 24 AFE clock periods
 
#define AFEC_STARTUP_SUT64   (4U)
 64 AFE clock periods
 
#define AFEC_STARTUP_SUT80   (5U)
 80 AFE clock periods
 
#define AFEC_STARTUP_SUT96   (6U)
 96 AFE clock periods
 
#define AFEC_STARTUP_SUT112   (7U)
 112 AFE clock periods
 
#define AFEC_STARTUP_SUT512   (8U)
 512 AFE clock periods
 
#define AFEC_STARTUP_SUT576   (9U)
 576 AFE clock periods
 
#define AFEC_STARTUP_SUT640   (10U)
 640 AFE clock periods
 
#define AFEC_STARTUP_SUT704   (11U)
 704 AFE clock periods
 
#define AFEC_STARTUP_SUT768   (12U)
 768 AFE clock periods
 
#define AFEC_STARTUP_SUT832   (13U)
 832 AFE clock periods
 
#define AFEC_STARTUP_SUT896   (14U)
 896 AFE clock periods
 
#define AFEC_STARTUP_SUT960   (15U)
 960 AFE clock periods
 

AFEC Sign Mode Definitions

Sign mode values for use with AFEC_SIGN_MODE type.

#define AFEC_SIGNMODE_SE_UNSG_DF_SIGN   (0U)
 Single-ended unsigned, differential signed.
 
#define AFEC_SIGNMODE_SE_SIGN_DF_UNSG   (1U)
 Single-ended signed, differential unsigned.
 
#define AFEC_SIGNMODE_ALL_UNSIGNED   (2U)
 All channels unsigned.
 
#define AFEC_SIGNMODE_ALL_SIGNED   (3U)
 All channels signed.
 

AFEC Temperature Comparison Mode Definitions

Temperature comparison mode values for use with AFEC_TEMP_CMP_MODE type.

#define AFEC_TEMPCMPMODE_LOW   (0U)
 Event when temperature is below low threshold.
 
#define AFEC_TEMPCMPMODE_HIGH   (1U)
 Event when temperature is above high threshold.
 
#define AFEC_TEMPCMPMODE_IN   (2U)
 Event when temperature is within the comparison window.
 
#define AFEC_TEMPCMPMODE_OUT   (3U)
 Event when temperature is outside the comparison window.
 

Description

Driver API for AFEC (plib_afec0.h)

Macro Definition Documentation

◆ AFEC_CH0

#define AFEC_CH0   (0U)

AFEC Channel 0.

◆ AFEC_CH0_MASK

#define AFEC_CH0_MASK   (1U << 0U)

AFEC Channel 0 mask.

◆ AFEC_CH1

#define AFEC_CH1   (1U)

AFEC Channel 1.

◆ AFEC_CH10

#define AFEC_CH10   (10U)

AFEC Channel 10.

◆ AFEC_CH10_MASK

#define AFEC_CH10_MASK   (1U << 10U)

AFEC Channel 10 mask.

◆ AFEC_CH11

#define AFEC_CH11   (11U)

AFEC Channel 11.

◆ AFEC_CH11_MASK

#define AFEC_CH11_MASK   (1U << 11U)

AFEC Channel 11 mask.

◆ AFEC_CH1_MASK

#define AFEC_CH1_MASK   (1U << 1U)

AFEC Channel 1 mask.

◆ AFEC_CH2

#define AFEC_CH2   (2U)

AFEC Channel 2.

◆ AFEC_CH2_MASK

#define AFEC_CH2_MASK   (1U << 2U)

AFEC Channel 2 mask.

◆ AFEC_CH3

#define AFEC_CH3   (3U)

AFEC Channel 3.

◆ AFEC_CH3_MASK

#define AFEC_CH3_MASK   (1U << 3U)

AFEC Channel 3 mask.

◆ AFEC_CH4

#define AFEC_CH4   (4U)

AFEC Channel 4.

◆ AFEC_CH4_MASK

#define AFEC_CH4_MASK   (1U << 4U)

AFEC Channel 4 mask.

◆ AFEC_CH5

#define AFEC_CH5   (5U)

AFEC Channel 5.

◆ AFEC_CH5_MASK

#define AFEC_CH5_MASK   (1U << 5U)

AFEC Channel 5 mask.

◆ AFEC_CH6

#define AFEC_CH6   (6U)

AFEC Channel 6.

◆ AFEC_CH6_MASK

#define AFEC_CH6_MASK   (1U << 6U)

AFEC Channel 6 mask.

◆ AFEC_CH7

#define AFEC_CH7   (7U)

AFEC Channel 7.

◆ AFEC_CH7_MASK

#define AFEC_CH7_MASK   (1U << 7U)

AFEC Channel 7 mask.

◆ AFEC_CH8

#define AFEC_CH8   (8U)

AFEC Channel 8.

◆ AFEC_CH8_MASK

#define AFEC_CH8_MASK   (1U << 8U)

AFEC Channel 8 mask.

◆ AFEC_CH9

#define AFEC_CH9   (9U)

AFEC Channel 9.

◆ AFEC_CH9_MASK

#define AFEC_CH9_MASK   (1U << 9U)

AFEC Channel 9 mask.

◆ AFEC_COMPARATOR_MODE_HIGH

#define AFEC_COMPARATOR_MODE_HIGH   (1U)

Event when conversion is higher than high threshold.

◆ AFEC_COMPARATOR_MODE_IN

#define AFEC_COMPARATOR_MODE_IN   (2U)

Event when conversion is within the comparison window.

◆ AFEC_COMPARATOR_MODE_LOW

#define AFEC_COMPARATOR_MODE_LOW   (0U)

Event when conversion is lower than low threshold.

◆ AFEC_COMPARATOR_MODE_OUT

#define AFEC_COMPARATOR_MODE_OUT   (3U)

Event when conversion is outside the comparison window.

◆ AFEC_GAIN_X1

#define AFEC_GAIN_X1   (0U)

Gain x1 (no amplification)

◆ AFEC_GAIN_X2

#define AFEC_GAIN_X2   (1U)

Gain x2.

◆ AFEC_GAIN_X4

#define AFEC_GAIN_X4   (3U)

Gain x4.

◆ AFEC_INTERRUPT_COMPE_MASK

#define AFEC_INTERRUPT_COMPE_MASK   (1U << 26U)

Comparison Event interrupt mask.

◆ AFEC_INTERRUPT_DRDY_MASK

#define AFEC_INTERRUPT_DRDY_MASK   (1U << 24U)

Data Ready interrupt mask.

◆ AFEC_INTERRUPT_EOC0_MASK

#define AFEC_INTERRUPT_EOC0_MASK   (1U << 0U)

End of Conversion Channel 0 interrupt mask.

◆ AFEC_INTERRUPT_EOC10_MASK

#define AFEC_INTERRUPT_EOC10_MASK   (1U << 10U)

End of Conversion Channel 10 interrupt mask.

◆ AFEC_INTERRUPT_EOC11_MASK

#define AFEC_INTERRUPT_EOC11_MASK   (1U << 11U)

End of Conversion Channel 11 interrupt mask.

◆ AFEC_INTERRUPT_EOC1_MASK

#define AFEC_INTERRUPT_EOC1_MASK   (1U << 1U)

End of Conversion Channel 1 interrupt mask.

◆ AFEC_INTERRUPT_EOC2_MASK

#define AFEC_INTERRUPT_EOC2_MASK   (1U << 2U)

End of Conversion Channel 2 interrupt mask.

◆ AFEC_INTERRUPT_EOC3_MASK

#define AFEC_INTERRUPT_EOC3_MASK   (1U << 3U)

End of Conversion Channel 3 interrupt mask.

◆ AFEC_INTERRUPT_EOC4_MASK

#define AFEC_INTERRUPT_EOC4_MASK   (1U << 4U)

End of Conversion Channel 4 interrupt mask.

◆ AFEC_INTERRUPT_EOC5_MASK

#define AFEC_INTERRUPT_EOC5_MASK   (1U << 5U)

End of Conversion Channel 5 interrupt mask.

◆ AFEC_INTERRUPT_EOC6_MASK

#define AFEC_INTERRUPT_EOC6_MASK   (1U << 6U)

End of Conversion Channel 6 interrupt mask.

◆ AFEC_INTERRUPT_EOC7_MASK

#define AFEC_INTERRUPT_EOC7_MASK   (1U << 7U)

End of Conversion Channel 7 interrupt mask.

◆ AFEC_INTERRUPT_EOC8_MASK

#define AFEC_INTERRUPT_EOC8_MASK   (1U << 8U)

End of Conversion Channel 8 interrupt mask.

◆ AFEC_INTERRUPT_EOC9_MASK

#define AFEC_INTERRUPT_EOC9_MASK   (1U << 9U)

End of Conversion Channel 9 interrupt mask.

◆ AFEC_INTERRUPT_GOVRE_MASK

#define AFEC_INTERRUPT_GOVRE_MASK   (1U << 25U)

General Overrun Error interrupt mask.

◆ AFEC_INTERRUPT_TEMPCHG_MASK

#define AFEC_INTERRUPT_TEMPCHG_MASK   (1U << 30U)

Temperature Change interrupt mask.

◆ AFEC_RESOLUTION_12BIT

#define AFEC_RESOLUTION_12BIT   (0U)

12-bit resolution, no averaging

◆ AFEC_RESOLUTION_13BIT_OSR4

#define AFEC_RESOLUTION_13BIT_OSR4   (2U)

13-bit resolution with 4x oversampling

◆ AFEC_RESOLUTION_14BIT_OSR16

#define AFEC_RESOLUTION_14BIT_OSR16   (3U)

14-bit resolution with 16x oversampling

◆ AFEC_RESOLUTION_15BIT_OSR64

#define AFEC_RESOLUTION_15BIT_OSR64   (4U)

15-bit resolution with 64x oversampling

◆ AFEC_RESOLUTION_16BIT_OSR256

#define AFEC_RESOLUTION_16BIT_OSR256   (5U)

16-bit resolution with 256x oversampling

◆ AFEC_SIGNMODE_ALL_SIGNED

#define AFEC_SIGNMODE_ALL_SIGNED   (3U)

All channels signed.

◆ AFEC_SIGNMODE_ALL_UNSIGNED

#define AFEC_SIGNMODE_ALL_UNSIGNED   (2U)

All channels unsigned.

◆ AFEC_SIGNMODE_SE_SIGN_DF_UNSG

#define AFEC_SIGNMODE_SE_SIGN_DF_UNSG   (1U)

Single-ended signed, differential unsigned.

◆ AFEC_SIGNMODE_SE_UNSG_DF_SIGN

#define AFEC_SIGNMODE_SE_UNSG_DF_SIGN   (0U)

Single-ended unsigned, differential signed.

◆ AFEC_STARTUP_SUT0

#define AFEC_STARTUP_SUT0   (0U)

0 AFE clock periods

◆ AFEC_STARTUP_SUT112

#define AFEC_STARTUP_SUT112   (7U)

112 AFE clock periods

◆ AFEC_STARTUP_SUT16

#define AFEC_STARTUP_SUT16   (2U)

16 AFE clock periods

◆ AFEC_STARTUP_SUT24

#define AFEC_STARTUP_SUT24   (3U)

24 AFE clock periods

◆ AFEC_STARTUP_SUT512

#define AFEC_STARTUP_SUT512   (8U)

512 AFE clock periods

◆ AFEC_STARTUP_SUT576

#define AFEC_STARTUP_SUT576   (9U)

576 AFE clock periods

◆ AFEC_STARTUP_SUT64

#define AFEC_STARTUP_SUT64   (4U)

64 AFE clock periods

◆ AFEC_STARTUP_SUT640

#define AFEC_STARTUP_SUT640   (10U)

640 AFE clock periods

◆ AFEC_STARTUP_SUT704

#define AFEC_STARTUP_SUT704   (11U)

704 AFE clock periods

◆ AFEC_STARTUP_SUT768

#define AFEC_STARTUP_SUT768   (12U)

768 AFE clock periods

◆ AFEC_STARTUP_SUT8

#define AFEC_STARTUP_SUT8   (1U)

8 AFE clock periods

◆ AFEC_STARTUP_SUT80

#define AFEC_STARTUP_SUT80   (5U)

80 AFE clock periods

◆ AFEC_STARTUP_SUT832

#define AFEC_STARTUP_SUT832   (13U)

832 AFE clock periods

◆ AFEC_STARTUP_SUT896

#define AFEC_STARTUP_SUT896   (14U)

896 AFE clock periods

◆ AFEC_STARTUP_SUT96

#define AFEC_STARTUP_SUT96   (6U)

96 AFE clock periods

◆ AFEC_STARTUP_SUT960

#define AFEC_STARTUP_SUT960   (15U)

960 AFE clock periods

◆ AFEC_TEMPCMPMODE_HIGH

#define AFEC_TEMPCMPMODE_HIGH   (1U)

Event when temperature is above high threshold.

◆ AFEC_TEMPCMPMODE_IN

#define AFEC_TEMPCMPMODE_IN   (2U)

Event when temperature is within the comparison window.

◆ AFEC_TEMPCMPMODE_LOW

#define AFEC_TEMPCMPMODE_LOW   (0U)

Event when temperature is below low threshold.

◆ AFEC_TEMPCMPMODE_OUT

#define AFEC_TEMPCMPMODE_OUT   (3U)

Event when temperature is outside the comparison window.

◆ AFEC_TRIGGER_ADTRG

#define AFEC_TRIGGER_ADTRG   (0U)

External trigger (ADTRG pin)

◆ AFEC_TRIGGER_ANALOG_COMP

#define AFEC_TRIGGER_ANALOG_COMP   (6U)

Analog Comparator.

◆ AFEC_TRIGGER_PWM_EVENT0

#define AFEC_TRIGGER_PWM_EVENT0   (4U)

PWM Event Line 0.

◆ AFEC_TRIGGER_PWM_EVENT1

#define AFEC_TRIGGER_PWM_EVENT1   (5U)

PWM Event Line 1.

◆ AFEC_TRIGGER_TIOA0

#define AFEC_TRIGGER_TIOA0   (1U)

Timer Counter Channel 0 Output A.

◆ AFEC_TRIGGER_TIOA1

#define AFEC_TRIGGER_TIOA1   (2U)

Timer Counter Channel 1 Output A.

◆ AFEC_TRIGGER_TIOA2

#define AFEC_TRIGGER_TIOA2   (3U)

Timer Counter Channel 2 Output A.

Typedef Documentation

◆ AFEC_CALLBACK

AFEC_CALLBACK

AFEC interrupt callback type with context (Harmony compatible).

Defines the prototype for AFEC interrupt callback functions with user context. Use this with AFECx_CallbackRegister() for applications that need to pass user-defined context (e.g., object pointers, state data) to the callback.

This is the recommended callback pattern for new designs as it provides better modularity and compatibility with MPLAB Harmony 3 style APIs.

Parameters
statusThe interrupt status register value that triggered the callback.
contextUser-defined context value passed during callback registration.

◆ AFEC_CALLBACK_HANDLER

AFEC_CALLBACK_HANDLER

Simple AFEC interrupt callback handler type.

Defines the prototype for simple AFEC interrupt callback functions. Use this with AFECx_SetCallbackHandler() for simple applications that don't need to pass user context to the callback.

Note
For new designs, consider using AFEC_CALLBACK with AFECx_CallbackRegister() which provides context-passing capability for better modularity.
Parameters
statusThe interrupt status register value that triggered the callback.

◆ AFEC_CHANNEL_GAIN

AFEC channel gain selection.

This type specifies the gain for the programmable gain amplifier.

◆ AFEC_CHANNEL_MASK

AFEC channel mask for enabling/disabling multiple channels.

This type specifies a bitmask of channels.

◆ AFEC_CHANNEL_NUM

AFEC channel number selection.

This type specifies the AFEC channel number (0-11).

◆ AFEC_COMPARATOR_MODE

AFEC comparator mode selection.

This type specifies the comparison mode for window monitoring.

◆ AFEC_INTERRUPT_MASK

AFEC interrupt mask for enabling/disabling interrupts.

This type specifies a bitmask of interrupt sources.

◆ AFEC_RESOLUTION

AFEC resolution selection.

This type specifies the resolution and averaging mode.

◆ AFEC_SIGN_MODE

AFEC sign mode selection.

This type specifies the sign mode for conversion results.

◆ AFEC_STARTUP_TIME

AFEC startup time selection.

This type specifies the startup time in AFE clock periods.

◆ AFEC_TEMP_CMP_MODE

AFEC temperature comparison mode selection.

This type specifies the temperature comparison mode.

◆ AFEC_TRIGGER_SOURCE

AFEC trigger source selection.

This type specifies the hardware trigger source.

Function Documentation

◆ AFEC0_CallbackRegister()

void AFEC0_CallbackRegister ( AFEC_CALLBACK callback,
uintptr_t context )

Registers a callback with context (Harmony compatible).

Sets a user-defined callback function with context to be invoked when an AFEC0 interrupt occurs.

Parameters
callbackPointer to the callback function.
contextUser-defined context value passed to the callback.
Returns
None.

◆ AFEC0_ChannelDifferentialModeSet()

void AFEC0_ChannelDifferentialModeSet ( AFEC_CHANNEL_NUM channel,
bool enable )

Sets a channel to differential mode.

Configures a channel for differential input operation.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
enableTrue for differential mode, false for single-ended.
Returns
None.

◆ AFEC0_ChannelDualSampleHoldSet()

void AFEC0_ChannelDualSampleHoldSet ( AFEC_CHANNEL_NUM channel,
bool enable )

Sets a channel to dual sample-and-hold mode.

Configures a channel for dual sample-and-hold operation.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
enableTrue for dual S&H mode, false for single S&H.
Returns
None.

◆ AFEC0_ChannelErrorCorrectionEnable()

void AFEC0_ChannelErrorCorrectionEnable ( AFEC_CHANNEL_NUM channel,
bool enable )

Enables error correction for a channel.

Enables automatic error correction for the specified channel.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
enableTrue to enable, false to disable.
Returns
None.

◆ AFEC0_ChannelGainSet()

void AFEC0_ChannelGainSet ( AFEC_CHANNEL_NUM channel,
AFEC_CHANNEL_GAIN gain )

Sets the channel gain.

Configures the programmable gain amplifier for a channel.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
gainGain selection (see AFEC_CHANNEL_GAIN).
Returns
None.

◆ AFEC0_ChannelOffsetSet()

void AFEC0_ChannelOffsetSet ( AFEC_CHANNEL_NUM channel,
uint16_t offset )

Sets the channel offset.

Configures the analog offset compensation for a channel.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
offsetOffset value (0-1023, 512 = no offset).
Returns
None.

◆ AFEC0_ChannelResultGet()

uint16_t AFEC0_ChannelResultGet ( AFEC_CHANNEL_NUM channel)

Gets the conversion result for a channel.

Returns the conversion result for the specified channel.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
Returns
16-bit conversion result.

◆ AFEC0_ChannelResultIsReady()

bool AFEC0_ChannelResultIsReady ( AFEC_CHANNEL_NUM channel)

Checks if channel result is ready.

Returns true if conversion result is available for the specified channel.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
Returns
true if result is ready, false otherwise.

◆ AFEC0_ChannelsDisable()

void AFEC0_ChannelsDisable ( AFEC_CHANNEL_MASK channelsMask)

Disables AFEC0 channels.

Disables the specified channels.

Parameters
channelsMaskBitmask of channels to disable (see AFEC_CHANNEL_MASK).
Returns
None.

◆ AFEC0_ChannelsEnable()

void AFEC0_ChannelsEnable ( AFEC_CHANNEL_MASK channelsMask)

Enables AFEC0 channels.

Enables the specified channels for conversion.

Parameters
channelsMaskBitmask of channels to enable (see AFEC_CHANNEL_MASK).
Returns
None.

◆ AFEC0_ChannelsInterruptDisable()

void AFEC0_ChannelsInterruptDisable ( AFEC_INTERRUPT_MASK channelsInterruptMask)

Disables channel end of conversion interrupts.

Disables the specified channel interrupt sources.

Parameters
channelsInterruptMaskBitmask of channel interrupts to disable (see AFEC_INTERRUPT_MASK).
Returns
None.

◆ AFEC0_ChannelsInterruptEnable()

void AFEC0_ChannelsInterruptEnable ( AFEC_INTERRUPT_MASK channelsInterruptMask)

Enables channel end of conversion interrupts.

Enables the specified channel interrupt sources.

Parameters
channelsInterruptMaskBitmask of channel interrupts to enable (see AFEC_INTERRUPT_MASK).
Returns
None.

◆ AFEC0_ChannelsStatusGet()

uint32_t AFEC0_ChannelsStatusGet ( void )

Gets the channel status.

Returns the current channel enable status.

Parameters
None.
Returns
Bitmask of enabled channels.

◆ AFEC0_ComparatorChannelSet()

void AFEC0_ComparatorChannelSet ( AFEC_CHANNEL_NUM channel)

Sets the comparator channel.

Configures which channel is used for comparison.

Parameters
channelChannel number (see AFEC_CHANNEL_NUM).
Returns
None.

◆ AFEC0_ComparatorFilterSet()

void AFEC0_ComparatorFilterSet ( uint8_t filter)

Sets the comparison filter.

Sets the number of consecutive comparison errors needed to raise flag.

Parameters
filterFilter value (0-3, number of comparisons = filter + 1).
Returns
None.

◆ AFEC0_ComparatorModeSet()

void AFEC0_ComparatorModeSet ( AFEC_COMPARATOR_MODE cmpMode)

Sets the comparator mode.

Configures the comparison mode (low, high, in, out).

Parameters
cmpModeComparator mode selection (see AFEC_COMPARATOR_MODE).
Returns
None.

◆ AFEC0_ComparatorStatusGet()

bool AFEC0_ComparatorStatusGet ( void )

Gets the comparator status.

Returns true if a comparison event has occurred.

Parameters
None.
Returns
true if comparison event occurred, false otherwise.

◆ AFEC0_CompareAllChannelsDisable()

void AFEC0_CompareAllChannelsDisable ( void )

Disables comparison on all channels.

When disabled, only the selected channel is compared.

Parameters
None.
Returns
None.

◆ AFEC0_CompareAllChannelsEnable()

void AFEC0_CompareAllChannelsEnable ( void )

Enables comparison on all channels.

When enabled, all channels are compared against the window.

Parameters
None.
Returns
None.

◆ AFEC0_CompareWindowSet()

void AFEC0_CompareWindowSet ( uint16_t lowThreshold,
uint16_t highThreshold )

Configures the comparison window.

Sets the low and high thresholds for comparison.

Parameters
lowThresholdLow threshold value (16-bit).
highThresholdHigh threshold value (16-bit).
Returns
None.

◆ AFEC0_ConversionSequenceSet()

void AFEC0_ConversionSequenceSet ( const AFEC_CHANNEL_NUM * channelList,
uint8_t numChannel )

Configures the user-defined conversion sequence.

Sets the channel conversion sequence for user sequence mode.

Parameters
channelListPointer to array of channel numbers.
numChannelNumber of channels in the sequence (max 12).
Returns
None.

◆ AFEC0_ConversionStart()

void AFEC0_ConversionStart ( void )

Starts an AFEC0 conversion.

Initiates a software-triggered conversion on enabled channels.

Parameters
None.
Returns
None.

◆ AFEC0_CorrectionSelectSet()

void AFEC0_CorrectionSelectSet ( uint8_t shUnit)

Selects the sample-and-hold unit for correction.

Selects which S&H unit's correction values are accessed.

Parameters
shUnitSample-and-hold unit (0 or 1).
Returns
None.

◆ AFEC0_CorrectionValuesSet()

void AFEC0_CorrectionValuesSet ( int16_t offsetCorr,
uint16_t gainCorr )

Sets the correction values.

Configures offset and gain correction values for the selected S&H unit.

Parameters
offsetCorrOffset correction value (16-bit signed).
gainCorrGain correction value (16-bit).
Returns
None.

◆ AFEC0_InterruptsDisable()

void AFEC0_InterruptsDisable ( AFEC_INTERRUPT_MASK interruptMask)

Disables AFEC0 interrupts.

Disables the specified interrupt sources.

Parameters
interruptMaskBitmask of interrupts to disable (see AFEC_INTERRUPT_MASK).
Returns
None.

◆ AFEC0_InterruptsEnable()

void AFEC0_InterruptsEnable ( AFEC_INTERRUPT_MASK interruptMask)

Enables AFEC0 interrupts.

Enables the specified interrupt sources.

Parameters
interruptMaskBitmask of interrupts to enable (see AFEC_INTERRUPT_MASK).
Returns
None.

◆ AFEC0_InterruptsMaskGet()

uint32_t AFEC0_InterruptsMaskGet ( void )

Gets the interrupt mask.

Returns the current interrupt enable mask.

Parameters
None.
Returns
Bitmask of enabled interrupts.

◆ AFEC0_LastConvertedChannelGet()

uint8_t AFEC0_LastConvertedChannelGet ( void )

Gets the channel number from last converted data.

Returns the channel number associated with last converted data (requires TAG mode).

Parameters
None.
Returns
Channel number (0-11).

◆ AFEC0_LastConvertedDataGet()

uint16_t AFEC0_LastConvertedDataGet ( void )

Gets the last converted data.

Returns the last converted data from LCDR register.

Parameters
None.
Returns
16-bit last converted data.

◆ AFEC0_OverrunStatusGet()

uint32_t AFEC0_OverrunStatusGet ( void )

Gets the overrun status.

Returns the overrun status for all channels.

Parameters
None.
Returns
Overrun status register value.

◆ AFEC0_PGA0Enable()

void AFEC0_PGA0Enable ( bool enable)

Enables PGA0.

Enables the Programmable Gain Amplifier 0.

Parameters
enableTrue to enable, false to disable.
Returns
None.

◆ AFEC0_PGA1Enable()

void AFEC0_PGA1Enable ( bool enable)

Enables PGA1.

Enables the Programmable Gain Amplifier 1.

Parameters
enableTrue to enable, false to disable.
Returns
None.

◆ AFEC0_SetBiasCurrentControl()

void AFEC0_SetBiasCurrentControl ( uint8_t ibctl)

Sets the AFE bias current control.

Configures the bias current for the analog front-end.

Parameters
ibctlBias current control value (0-3).
Returns
None.

◆ AFEC0_SetCallbackHandler()

void AFEC0_SetCallbackHandler ( AFEC_CALLBACK_HANDLER callback)

Registers a callback handler.

Sets a user-defined callback function to be invoked when an AFEC0 interrupt occurs.

Parameters
callbackPointer to the callback function.
Returns
None.

◆ AFEC0_SetFastWakeup()

void AFEC0_SetFastWakeup ( bool enable)

Enables or disables fast wakeup mode.

In fast wakeup mode, voltage reference stays ON between conversions.

Parameters
enableTrue to enable fast wakeup, false for normal sleep.
Returns
None.

◆ AFEC0_SetFreeRunMode()

void AFEC0_SetFreeRunMode ( bool enable)

Enables or disables free run mode.

In free run mode, AFEC0 continuously converts without waiting for triggers.

Parameters
enableTrue to enable, false to disable.
Returns
None.

◆ AFEC0_SetPrescaler()

void AFEC0_SetPrescaler ( uint8_t prescaler)

Sets the AFEC0 clock prescaler.

Configures the AFEC0 clock division factor relative to the peripheral clock. AFE Clock = Peripheral Clock / (PRESCAL + 1) This function also sets the ONE bit (bit 23) in the Mode Register as required by the datasheet. Call this function during AFEC initialization.

Parameters
prescalerPrescaler value (0-255).
Returns
None.

◆ AFEC0_SetResolution()

void AFEC0_SetResolution ( AFEC_RESOLUTION resolution)

Sets the AFEC0 resolution.

Configures the resolution and averaging/oversampling mode.

Parameters
resolutionResolution selection (see AFEC_RESOLUTION).
Returns
None.

◆ AFEC0_SetSignMode()

void AFEC0_SetSignMode ( AFEC_SIGN_MODE signmode)

Sets the AFEC0 sign mode.

Configures whether conversion results are signed or unsigned.

Parameters
signmodeSign mode selection (see AFEC_SIGN_MODE).
Returns
None.

◆ AFEC0_SetSingleTriggerMode()

void AFEC0_SetSingleTriggerMode ( bool enable)

Enables or disables single trigger mode.

When enabled, only a single trigger is required to get an averaged value.

Parameters
enableTrue to enable single trigger mode, false for multiple triggers.
Returns
None.

◆ AFEC0_SetSleepMode()

void AFEC0_SetSleepMode ( bool enable)

Enables or disables sleep mode.

In sleep mode, AFE and reference voltage are OFF between conversions.

Parameters
enableTrue to enable sleep mode, false for normal mode.
Returns
None.

◆ AFEC0_SetStartupTime()

void AFEC0_SetStartupTime ( AFEC_STARTUP_TIME startup)

Sets the AFEC0 startup time.

Configures the startup time in AFE clock periods.

Parameters
startupStartup time selection (see AFEC_STARTUP_TIME).
Returns
None.

◆ AFEC0_SetTagMode()

void AFEC0_SetTagMode ( bool enable)

Enables or disables TAG mode.

When enabled, channel number is appended to LCDR.

Parameters
enableTrue to enable TAG mode, false to disable.
Returns
None.

◆ AFEC0_SetTransferPeriod()

void AFEC0_SetTransferPeriod ( uint8_t transfer)

Sets the AFEC0 transfer period.

Configures the period between start command and channel selection.

Parameters
transferTransfer period value (0-3, recommended: 2).
Returns
None.

◆ AFEC0_SetTriggerEnable()

void AFEC0_SetTriggerEnable ( bool enable)

Enables hardware trigger.

Enables the hardware trigger selected by SetTriggerSource.

Parameters
enableTrue to enable hardware trigger, false for software trigger only.
Returns
None.

◆ AFEC0_SetTriggerSource()

void AFEC0_SetTriggerSource ( AFEC_TRIGGER_SOURCE trigger)

Sets the hardware trigger source.

Configures which hardware trigger source is used.

Parameters
triggerTrigger source selection (see AFEC_TRIGGER_SOURCE).
Returns
None.

◆ AFEC0_SetUserSequenceMode()

void AFEC0_SetUserSequenceMode ( bool enable)

Enables or disables user sequence mode.

In user sequence mode, the conversion sequence is defined by SEQ1R/SEQ2R.

Parameters
enableTrue to enable user sequence, false for numeric order.
Returns
None.

◆ AFEC0_SoftwareReset()

void AFEC0_SoftwareReset ( void )

Software reset of AFEC0.

Resets the AFEC0 module to its default state.

Parameters
None.
Returns
None.

◆ AFEC0_StatusGet()

uint32_t AFEC0_StatusGet ( void )

Gets the interrupt status.

Returns the current interrupt status register (AFEC_ISR). Note: Reading AFEC_ISR clears only GOVRE, COMPE, and TEMPCHG flags. EOCx flags are cleared by reading AFEC_CDRx (via ChannelResultGet). DRDY flag is cleared by reading AFEC_LCDR (via LastConvertedDataGet).

Parameters
None.
Returns
Interrupt status register value.

◆ AFEC0_TemperatureCompareWindowSet()

void AFEC0_TemperatureCompareWindowSet ( uint16_t lowThreshold,
uint16_t highThreshold )

Sets the temperature comparison window.

Configures the low and high thresholds for temperature comparison.

Parameters
lowThresholdLow threshold value (16-bit).
highThresholdHigh threshold value (16-bit).
Returns
None.

◆ AFEC0_TemperatureComparisonModeSet()

void AFEC0_TemperatureComparisonModeSet ( AFEC_TEMP_CMP_MODE cmpMode)

Sets the temperature comparison mode.

Configures the temperature comparison mode.

Parameters
cmpModeTemperature comparison mode (see AFEC_TEMP_CMP_MODE).
Returns
None.

◆ AFEC0_TemperatureRTCTriggerEnable()

void AFEC0_TemperatureRTCTriggerEnable ( bool enable)

Enables temperature sensor RTC trigger.

When enabled, temperature sensor is triggered by RTC every second.

Parameters
enableTrue to enable RTC trigger, false to disable.
Returns
None.

◆ AFEC0_WriteProtectionEnable()

void AFEC0_WriteProtectionEnable ( bool enable)

Enables write protection.

Enables write protection for AFEC0 registers.

Parameters
enableTrue to enable write protection, false to disable.
Returns
None.

◆ AFEC0_WriteProtectionStatusGet()

uint32_t AFEC0_WriteProtectionStatusGet ( void )

Gets write protection violation status.

Returns information about write protection violations.

Parameters
None.
Returns
Write protection status register value.