CMSIS-Driver_PIC32CM-JH  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
SUPC Interface

Driver API for SUPC (plib_supc.h) More...

Macros

#define SUPC_BODVDD_ACTCFG_ENABLE   1
 
#define SUPC_BODVDD_ACTCFG_DISABLE   0
 
#define SUPC_BODVDD_STDBYCFG_ENABLE   1
 
#define SUPC_BODVDD_STDBYCFG_DISABLE   0
 
#define SUPC_BODVDD_RUNSTDBY_ENABLE   1
 
#define SUPC_BODVDD_RUNSTDBY_DISABLE   0
 
#define SUPC_BODVDD_HYST_ENABLE   1
 
#define SUPC_BODVDD_HYST_DISABLE   0
 
#define SUPC_VREG_ENABLE_VAL   1
 
#define SUPC_VREG_DISABLE   0
 
#define SUPC_VREG_RUNSTDBY_ENABLE   1
 
#define SUPC_VREG_RUNSTDBY_DISABLE   0
 
#define SUPC_VREF_VREFOE_ENABLE   1
 
#define SUPC_VREF_VREFOE_DISABLE   0
 
#define SUPC_VREF_ONDEMAND_ENABLE   1
 
#define SUPC_VREF_ONDEMAND_DISABLE   0
 
#define SUPC_VREF_RUNSTDBY_ENABLE   1
 
#define SUPC_VREF_RUNSTDBY_DISABLE   0
 

Typedefs

typedef void(* SUPC_CALLBACK_HANDLER) (uint32_t int_cause)
 SUPC callback function type.
 

Functions

void SUPC_EnableInterrupt (uint32_t interrupt_mask)
 Enable selected SUPC interrupts.
 
void SUPC_DisableInterrupt (uint32_t interrupt_mask)
 Disable selected SUPC interrupts.
 
void SUPC_BODVDD_Enable (void)
 Enable the Brown-Out Detector on VDD (BODVDD).
 
void SUPC_BODVDD_Disable (void)
 Disable the Brown-Out Detector on VDD (BODVDD).
 
void SUPC_BODVDD_SetLevel (uint32_t bod_level)
 Set BODVDD threshold level (must be called when BODVDD is disabled).
 
void SUPC_BODVDD_SetAction (uint32_t bod_action)
 Set BODVDD action (must be called when BODVDD is disabled).
 
void SUPC_BODVDD_EnableHysteresis (uint32_t enable)
 Enable or disable BODVDD hysteresis (must be called when BODVDD is disabled).
 
void SUPC_BODVDD_SetMode (uint32_t act_cfg, uint32_t stdby_cfg)
 Set BODVDD mode (active and standby) (must be called when BODVDD is disabled). If both actcfg and stdbycfg are disabled, BODVDD operates in continuous mode. If both actcfg and stdbycfg are enabled, BODVDD operates in sample mode.
 
void SUPC_BODVDD_EnableRunInStandby (uint32_t enable)
 Enable or disable BODVDD run in standby (must be called when BODVDD is disabled).
 
void SUPC_BODVDD_SetPrescaler (uint32_t prescaler)
 Set BODVDD prescaler (must be called when BODVDD is disabled).
 
void SUPC_VREG_Configure (uint32_t enable, uint32_t run_stdby)
 Configure the main voltage regulator (VREG).
 
void SUPC_VREF_Configure (uint32_t sel, uint32_t vref_oe, uint32_t run_stdby, uint32_t on_demand)
 Configure the reference voltage (VREF) for ADC/DAC.
 
void SUPC_SetCallbackHandler (SUPC_CALLBACK_HANDLER callback)
 Register a callback handler for SUPC interrupts.
 
bool SUPC_BODVDD_IsReady (void)
 Check if BODVDD is ready for use/configuration.
 
bool SUPC_BODVDD_IsDetected (void)
 Check if a brown-out is currently detected (VDD below threshold).
 
bool SUPC_BODVDD_IsSyncReady (void)
 Check if BODVDD enable/disable/configuration is synchronized.
 

Description

Driver API for SUPC (plib_supc.h)

Usage Example

The following example demonstrates typical usage of the SUPC peripheral:

#include "plib_supc.h"
#include <stdint.h>
#include <stdbool.h>
void SUPC_Callback(uint32_t int_cause)
{
if ((int_cause & SUPC_INTENSET_BODVDDDET_Msk) != 0U)
{
// User operation (e.g., LED toggle, print message)
}
}
int configure_supc(void)
{
/* Disable BODVDD before configuration */
/* Set BODVDD threshold level (example: LEVEL=0x10 for 2.7V) */
/* Configure BODVDD to generate a reset on threshold crossing */
SUPC_BODVDD_SetAction(SUPC_BODVDD_ACTION_RESET_Val);
/* Enable hysteresis for BODVDD to reduce sensitivity to voltage ripples */
/* Set BODVDD to continuous mode in both active and standby */
/* Disable run in standby for BODVDD */
/* Set BODVDD prescaler (example: DIV32 for sampling mode, ignored in continuous mode) */
SUPC_BODVDD_SetPrescaler(SUPC_BODVDD_PSEL_DIV32_Val);
/* Enable BODVDD after configuration */
/* Configure the main voltage regulator (VREG): enable, do not run in standby */
/* Configure the voltage reference (VREF): 1.024V, output disabled, not running in standby, not on-demand */
SUPC_VREF_SEL_1V024_Val,
);
/* Register the SUPC interrupt callback handler after configuration */
SUPC_SetCallbackHandler(&SUPC_Callback);
return 0;
}
#define SUPC_BODVDD_STDBYCFG_DISABLE
Definition plib_supc.h:62
void SUPC_BODVDD_Enable(void)
Enable the Brown-Out Detector on VDD (BODVDD).
#define SUPC_VREG_RUNSTDBY_DISABLE
Definition plib_supc.h:72
void SUPC_BODVDD_SetMode(uint32_t act_cfg, uint32_t stdby_cfg)
Set BODVDD mode (active and standby) (must be called when BODVDD is disabled). If both actcfg and std...
void SUPC_BODVDD_SetAction(uint32_t bod_action)
Set BODVDD action (must be called when BODVDD is disabled).
void SUPC_VREF_Configure(uint32_t sel, uint32_t vref_oe, uint32_t run_stdby, uint32_t on_demand)
Configure the reference voltage (VREF) for ADC/DAC.
#define SUPC_VREG_ENABLE_VAL
Definition plib_supc.h:69
void SUPC_BODVDD_SetLevel(uint32_t bod_level)
Set BODVDD threshold level (must be called when BODVDD is disabled).
void SUPC_VREG_Configure(uint32_t enable, uint32_t run_stdby)
Configure the main voltage regulator (VREG).
void SUPC_BODVDD_EnableRunInStandby(uint32_t enable)
Enable or disable BODVDD run in standby (must be called when BODVDD is disabled).
void SUPC_BODVDD_Disable(void)
Disable the Brown-Out Detector on VDD (BODVDD).
#define SUPC_VREF_VREFOE_DISABLE
Definition plib_supc.h:76
void SUPC_BODVDD_SetPrescaler(uint32_t prescaler)
Set BODVDD prescaler (must be called when BODVDD is disabled).
#define SUPC_VREF_ONDEMAND_DISABLE
Definition plib_supc.h:78
#define SUPC_BODVDD_ACTCFG_DISABLE
Definition plib_supc.h:60
#define SUPC_BODVDD_RUNSTDBY_DISABLE
Definition plib_supc.h:64
void SUPC_BODVDD_EnableHysteresis(uint32_t enable)
Enable or disable BODVDD hysteresis (must be called when BODVDD is disabled).
void SUPC_SetCallbackHandler(SUPC_CALLBACK_HANDLER callback)
Register a callback handler for SUPC interrupts.
#define SUPC_VREF_RUNSTDBY_DISABLE
Definition plib_supc.h:80
#define SUPC_BODVDD_HYST_ENABLE
Definition plib_supc.h:65

Macro Definition Documentation

◆ SUPC_BODVDD_ACTCFG_DISABLE

#define SUPC_BODVDD_ACTCFG_DISABLE   0

◆ SUPC_BODVDD_ACTCFG_ENABLE

#define SUPC_BODVDD_ACTCFG_ENABLE   1

◆ SUPC_BODVDD_HYST_DISABLE

#define SUPC_BODVDD_HYST_DISABLE   0

◆ SUPC_BODVDD_HYST_ENABLE

#define SUPC_BODVDD_HYST_ENABLE   1

◆ SUPC_BODVDD_RUNSTDBY_DISABLE

#define SUPC_BODVDD_RUNSTDBY_DISABLE   0

◆ SUPC_BODVDD_RUNSTDBY_ENABLE

#define SUPC_BODVDD_RUNSTDBY_ENABLE   1

◆ SUPC_BODVDD_STDBYCFG_DISABLE

#define SUPC_BODVDD_STDBYCFG_DISABLE   0

◆ SUPC_BODVDD_STDBYCFG_ENABLE

#define SUPC_BODVDD_STDBYCFG_ENABLE   1

◆ SUPC_VREF_ONDEMAND_DISABLE

#define SUPC_VREF_ONDEMAND_DISABLE   0

◆ SUPC_VREF_ONDEMAND_ENABLE

#define SUPC_VREF_ONDEMAND_ENABLE   1

◆ SUPC_VREF_RUNSTDBY_DISABLE

#define SUPC_VREF_RUNSTDBY_DISABLE   0

◆ SUPC_VREF_RUNSTDBY_ENABLE

#define SUPC_VREF_RUNSTDBY_ENABLE   1

◆ SUPC_VREF_VREFOE_DISABLE

#define SUPC_VREF_VREFOE_DISABLE   0

◆ SUPC_VREF_VREFOE_ENABLE

#define SUPC_VREF_VREFOE_ENABLE   1

◆ SUPC_VREG_DISABLE

#define SUPC_VREG_DISABLE   0

◆ SUPC_VREG_ENABLE_VAL

#define SUPC_VREG_ENABLE_VAL   1

◆ SUPC_VREG_RUNSTDBY_DISABLE

#define SUPC_VREG_RUNSTDBY_DISABLE   0

◆ SUPC_VREG_RUNSTDBY_ENABLE

#define SUPC_VREG_RUNSTDBY_ENABLE   1

Typedef Documentation

◆ SUPC_CALLBACK_HANDLER

SUPC_CALLBACK_HANDLER

SUPC callback function type.

This type defines a callback function for SUPC interrupts.

Parameters
int_causeThe interrupt cause.

Function Documentation

◆ SUPC_BODVDD_Disable()

void SUPC_BODVDD_Disable ( void )

Disable the Brown-Out Detector on VDD (BODVDD).

Clears the enable bit for BODVDD. Waits for synchronization before returning. Only disables if not already disabled.

◆ SUPC_BODVDD_Enable()

void SUPC_BODVDD_Enable ( void )

Enable the Brown-Out Detector on VDD (BODVDD).

Sets the enable bit for BODVDD. Waits for synchronization before returning. Only enables if not already enabled.

◆ SUPC_BODVDD_EnableHysteresis()

void SUPC_BODVDD_EnableHysteresis ( uint32_t enable)

Enable or disable BODVDD hysteresis (must be called when BODVDD is disabled).

Parameters
enableSUPC_BODVDD_HYST_ENABLE to enable, SUPC_BODVDD_HYST_DISABLE to disable.

◆ SUPC_BODVDD_EnableRunInStandby()

void SUPC_BODVDD_EnableRunInStandby ( uint32_t enable)

Enable or disable BODVDD run in standby (must be called when BODVDD is disabled).

Parameters
enableSUPC_BODVDD_RUNSTDBY_ENABLE to enable, SUPC_BODVDD_RUNSTDBY_DISABLE to disable.

◆ SUPC_BODVDD_IsDetected()

bool SUPC_BODVDD_IsDetected ( void )

Check if a brown-out is currently detected (VDD below threshold).

Returns
true if brown-out is detected, false otherwise.

◆ SUPC_BODVDD_IsReady()

bool SUPC_BODVDD_IsReady ( void )

Check if BODVDD is ready for use/configuration.

Returns
true if BODVDD is ready, false otherwise.

◆ SUPC_BODVDD_IsSyncReady()

bool SUPC_BODVDD_IsSyncReady ( void )

Check if BODVDD enable/disable/configuration is synchronized.

Returns
true if synchronization is complete, false otherwise.

◆ SUPC_BODVDD_SetAction()

void SUPC_BODVDD_SetAction ( uint32_t bod_action)

Set BODVDD action (must be called when BODVDD is disabled).

Parameters
bod_actionAction. @usage SUPC_BODVDD_SetAction(SUPC_BODVDD_ACTION_RESET);

◆ SUPC_BODVDD_SetLevel()

void SUPC_BODVDD_SetLevel ( uint32_t bod_level)

Set BODVDD threshold level (must be called when BODVDD is disabled).

Parameters
bod_levelThreshold value (use macro SUPC_BODVDD_LEVEL(value)).

The BODVDD LEVEL field [5:0] and HYST field determine the typical voltage threshold. See the table below for example values:

LEVEL (hex) HYST Typical Threshold (V)
0x00 0 2.37
0x08 0 2.74
0x08 1 2.94
0x3F 0 5.48
0x3F 1 5.57

@usage Set BODVDD threshold to 2.74V (LEVEL=0x08, HYST=0) SUPC_BODVDD_SetLevel(SUPC_BODVDD_LEVEL(0x08)); SUPC_BODVDD_EnableHysteresis(SUPC_BODVDD_HYST_DISABLE);

Set BODVDD threshold to 2.94V (LEVEL=0x08, HYST=1) SUPC_BODVDD_SetLevel(SUPC_BODVDD_LEVEL(0x08)); SUPC_BODVDD_EnableHysteresis(SUPC_BODVDD_HYST_ENABLE);

◆ SUPC_BODVDD_SetMode()

void SUPC_BODVDD_SetMode ( uint32_t act_cfg,
uint32_t stdby_cfg )

Set BODVDD mode (active and standby) (must be called when BODVDD is disabled). If both actcfg and stdbycfg are disabled, BODVDD operates in continuous mode. If both actcfg and stdbycfg are enabled, BODVDD operates in sample mode.

Parameters
actcfgActive mode config.
stdbycfgStandby mode config.

◆ SUPC_BODVDD_SetPrescaler()

void SUPC_BODVDD_SetPrescaler ( uint32_t prescaler)

Set BODVDD prescaler (must be called when BODVDD is disabled).

Parameters
prescalerPrescaler value (e.g., SUPC_BODVDD_PSEL_DIV32_VAL).

◆ SUPC_DisableInterrupt()

void SUPC_DisableInterrupt ( uint32_t interrupt_mask)

Disable selected SUPC interrupts.

Parameters
interrupt_maskBitmask of interrupts to disable (use SUPC_INTENCLR_*_MSK).

Sets the corresponding bits in the INTENCLR register to disable SUPC interrupts.

◆ SUPC_EnableInterrupt()

void SUPC_EnableInterrupt ( uint32_t interrupt_mask)

Enable selected SUPC interrupts.

Parameters
interrupt_maskBitmask of interrupts to enable (use SUPC_INTENSET_*_MSK).

Sets the corresponding bits in the INTENSET register to enable SUPC interrupts.

◆ SUPC_SetCallbackHandler()

void SUPC_SetCallbackHandler ( SUPC_CALLBACK_HANDLER callback)

Register a callback handler for SUPC interrupts.

Parameters
callbackFunction pointer to the callback handler.

The callback is called from the SUPC interrupt handler with the interrupt flags.

◆ SUPC_VREF_Configure()

void SUPC_VREF_Configure ( uint32_t sel,
uint32_t vref_oe,
uint32_t run_stdby,
uint32_t on_demand )

Configure the reference voltage (VREF) for ADC/DAC.

Parameters
selVoltage reference selection (e.g., SUPC_VREF_SEL_1V024_VAL).
vref_oeOutput enable (0=disable, 1=enable).
run_stdbyRun in standby (0=disable, 1=enable).
on_demandOn-demand control (0=always on, 1=on demand).

Sets the VREF configuration register.

◆ SUPC_VREG_Configure()

void SUPC_VREG_Configure ( uint32_t enable,
uint32_t run_stdby )

Configure the main voltage regulator (VREG).

Parameters
enable0=disable, 1=enable.
run_stdby0=disable in standby, 1=enable in standby.

Sets the VREG enable and standby configuration.