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

Driver API for DACC (plib_dacc.h) More...

Typedefs

typedef uint32_t DACC_CHANNEL_NUM
 Type definition representing a DACC channel number (0/1).
 
typedef void(* DACC_CALLBACK) (uint32_t status)
 Function pointer type for DACC event callback.
 

Enumerations

enum  DACC_IBCTL_MODE { DACC_IBCTL_BYPASS = 0U , DACC_IBCTL_LOW_POWER = 1U , DACC_IBCTL_NORMAL = 2U , DACC_IBCTL_HIGH_POWER = 3U }
 Enumeration for DACC analog output current bias (IBCTL) mode selection. More...
 

Functions

void DACC_ResetSoftware (void)
 Performs a software reset of the DACC peripheral.
 
void DACC_EnableChannel (DACC_CHANNEL_NUM channel)
 Enables the specified DACC output channel.
 
void DACC_DisableChannel (DACC_CHANNEL_NUM channel)
 Disables the specified DACC output channel.
 
bool DACC_IsReady (DACC_CHANNEL_NUM channel)
 Checks whether the specified DACC channel end-of-conversion is ready.
 
bool DACC_IsTXReady (DACC_CHANNEL_NUM channel)
 Checks whether the specified DACC channel transmit buffer is ready for new data.
 
void DACC_WriteData (DACC_CHANNEL_NUM channel, uint16_t data)
 Writes a half-word data value to the specified DACC channel.
 
void DACC_WriteDataWord (DACC_CHANNEL_NUM channel, uint16_t data0, uint16_t data1)
 Writes a word (dual channel data) to the DACC in word transfer mode.
 
void DACC_SetPrescaler (uint8_t prescaler)
 Sets the DACC peripheral clock prescaler value.
 
void DACC_EnableDifferentialMode (void)
 Enables differential mode for the DACC output.
 
void DACC_DisableDifferentialMode (void)
 Disables differential mode for the DACC output.
 
void DACC_EnableWordTransfer (void)
 Enables word transfer mode (both channels written simultaneously).
 
void DACC_DisableWordTransfer (void)
 Disables word transfer mode (channels written independently).
 
void DACC_EnableMaxSpeed (DACC_CHANNEL_NUM channel)
 Enables max speed mode for the specified DACC channel.
 
void DACC_DisableMaxSpeed (DACC_CHANNEL_NUM channel)
 Disables max speed mode for the specified DACC channel.
 
void DACC_EnableTrigger (DACC_CHANNEL_NUM channel, uint32_t trig_sel)
 Enables hardware trigger for the specified DACC channel and selects the trigger source.
 
void DACC_DisableTrigger (DACC_CHANNEL_NUM channel)
 Disables hardware trigger for the specified DACC channel (free-running mode).
 
void DACC_SetOSR (DACC_CHANNEL_NUM channel, uint32_t osr)
 Sets the oversampling ratio (OSR) for the specified DACC channel.
 
void DACC_SetAnalogCurrent (DACC_CHANNEL_NUM channel, DACC_IBCTL_MODE mode)
 Sets the analog output current bias (IBCTL) for the specified DACC channel.
 
void DACC_EnableWriteProtection (void)
 Enables write protection for the DACC configuration registers.
 
void DACC_DisableWriteProtection (void)
 Disables write protection for the DACC configuration registers.
 
bool DACC_GetWriteProtectionViolation (uint8_t *violation_src)
 Retrieves the write protection violation status.
 
void DACC_EnableInterrupt (uint32_t flag)
 Enables one or more DACC interrupt sources.
 
void DACC_DisableInterrupt (uint32_t flag)
 Disables one or more DACC interrupt sources.
 
void DACC_SetCallbackHandler (DACC_CALLBACK callback)
 Registers the callback function to be invoked from the DACC ISR.
 

Description

Driver API for DACC (plib_dacc.h)

Usage Example

The following example demonstrates typical usage of the DACC peripheral:

#include "plib_dacc.h"
#include <stdint.h>
#include <stdbool.h>
int32_t configure_dacc(void)
{
uint16_t dac_value = 0U;
const uint32_t DACC_CHANNEL_0 = 0U;
const uint8_t DACC_PRESCALER_VALUE = 0U;
/* Software reset of the DACC peripheral */
/* Disable write protection to allow register configuration.*/
/* Set clock prescaler to 0 */
DACC_SetPrescaler(DACC_PRESCALER_VALUE);
/* Single-ended output mode */
/* Independent channel write mode*/
/* Free-running mode*/
DACC_DisableTrigger(DACC_CHANNEL_0);
/* Normal conversion speed */
DACC_DisableMaxSpeed(DACC_CHANNEL_0);
/* Set analog output current bias to normal */
/* Enable DAC channel 0 */
DACC_EnableChannel(DACC_CHANNEL_0);
/* Re-enable write protection to guard configuration registers */
/* Wait for DAC channel to be ready */
while (DACC_IsReady(DACC_CHANNEL_0) == false)
{
/* Wait for DAC ready */
}
/* Wait for transmit buffer to be ready */
while (DACC_IsTXReady(DACC_CHANNEL_0) == false)
{
/* Wait for TX ready */
}
/* Write data to DAC channel 0 */
DACC_WriteData(DACC_CHANNEL_0, dac_value);
return 0;
}
void DACC_EnableWriteProtection(void)
Enables write protection for the DACC configuration registers.
void DACC_DisableWordTransfer(void)
Disables word transfer mode (channels written independently).
void DACC_DisableMaxSpeed(DACC_CHANNEL_NUM channel)
Disables max speed mode for the specified DACC channel.
void DACC_DisableDifferentialMode(void)
Disables differential mode for the DACC output.
void DACC_WriteData(DACC_CHANNEL_NUM channel, uint16_t data)
Writes a half-word data value to the specified DACC channel.
bool DACC_IsReady(DACC_CHANNEL_NUM channel)
Checks whether the specified DACC channel end-of-conversion is ready.
void DACC_ResetSoftware(void)
Performs a software reset of the DACC peripheral.
void DACC_EnableChannel(DACC_CHANNEL_NUM channel)
Enables the specified DACC output channel.
void DACC_DisableWriteProtection(void)
Disables write protection for the DACC configuration registers.
bool DACC_IsTXReady(DACC_CHANNEL_NUM channel)
Checks whether the specified DACC channel transmit buffer is ready for new data.
void DACC_DisableTrigger(DACC_CHANNEL_NUM channel)
Disables hardware trigger for the specified DACC channel (free-running mode).
void DACC_SetAnalogCurrent(DACC_CHANNEL_NUM channel, DACC_IBCTL_MODE mode)
Sets the analog output current bias (IBCTL) for the specified DACC channel.
void DACC_SetPrescaler(uint8_t prescaler)
Sets the DACC peripheral clock prescaler value.
@ DACC_IBCTL_NORMAL
Definition plib_dacc.h:67

Typedef Documentation

◆ DACC_CALLBACK

typedef void(* DACC_CALLBACK) (uint32_t status)

Function pointer type for DACC event callback.

Parameters
statusDACC interrupt status register value at the time of the interrupt.

◆ DACC_CHANNEL_NUM

typedef uint32_t DACC_CHANNEL_NUM

Type definition representing a DACC channel number (0/1).

Enumeration Type Documentation

◆ DACC_IBCTL_MODE

Enumeration for DACC analog output current bias (IBCTL) mode selection.

Enumerator
DACC_IBCTL_BYPASS 

Bypass mode (buffer off)

DACC_IBCTL_LOW_POWER 

Low Power Mode

DACC_IBCTL_NORMAL 

Normal Power Mode

DACC_IBCTL_HIGH_POWER 

High Power Mode

Function Documentation

◆ DACC_DisableChannel()

void DACC_DisableChannel ( DACC_CHANNEL_NUM channel)

Disables the specified DACC output channel.

Parameters
channelDACC channel number (0 or 1).
Returns
void

◆ DACC_DisableDifferentialMode()

void DACC_DisableDifferentialMode ( void )

Disables differential mode for the DACC output.

Returns
void

◆ DACC_DisableInterrupt()

void DACC_DisableInterrupt ( uint32_t flag)

Disables one or more DACC interrupt sources.

Parameters
flagBitwise OR of DACC_IDR_*_Msk values representing the interrupt sources to disable.
Returns
void

◆ DACC_DisableMaxSpeed()

void DACC_DisableMaxSpeed ( DACC_CHANNEL_NUM channel)

Disables max speed mode for the specified DACC channel.

Parameters
channelDACC channel number (0 or 1).
Returns
void

◆ DACC_DisableTrigger()

void DACC_DisableTrigger ( DACC_CHANNEL_NUM channel)

Disables hardware trigger for the specified DACC channel (free-running mode).

Parameters
channelDACC channel number (0 or 1).
Returns
void

◆ DACC_DisableWordTransfer()

void DACC_DisableWordTransfer ( void )

Disables word transfer mode (channels written independently).

Returns
void

◆ DACC_DisableWriteProtection()

void DACC_DisableWriteProtection ( void )

Disables write protection for the DACC configuration registers.

Returns
void

◆ DACC_EnableChannel()

void DACC_EnableChannel ( DACC_CHANNEL_NUM channel)

Enables the specified DACC output channel.

Parameters
channelDACC channel number (0 or 1).
Returns
void

◆ DACC_EnableDifferentialMode()

void DACC_EnableDifferentialMode ( void )

Enables differential mode for the DACC output.

Returns
void

◆ DACC_EnableInterrupt()

void DACC_EnableInterrupt ( uint32_t flag)

Enables one or more DACC interrupt sources.

Parameters
flagBitwise OR of DACC_IER_*_Msk values representing the interrupt sources to enable.
Returns
void

◆ DACC_EnableMaxSpeed()

void DACC_EnableMaxSpeed ( DACC_CHANNEL_NUM channel)

Enables max speed mode for the specified DACC channel.

Parameters
channelDACC channel number (0 or 1).
Returns
void

◆ DACC_EnableTrigger()

void DACC_EnableTrigger ( DACC_CHANNEL_NUM channel,
uint32_t trig_sel )

Enables hardware trigger for the specified DACC channel and selects the trigger source.

Parameters
channelDACC channel number (0 or 1).
trig_selTrigger source selection value (refer to DACC_TRIGR register field definitions).
Returns
void

◆ DACC_EnableWordTransfer()

void DACC_EnableWordTransfer ( void )

Enables word transfer mode (both channels written simultaneously).

Returns
void

◆ DACC_EnableWriteProtection()

void DACC_EnableWriteProtection ( void )

Enables write protection for the DACC configuration registers.

Returns
void

◆ DACC_GetWriteProtectionViolation()

bool DACC_GetWriteProtectionViolation ( uint8_t * violation_src)

Retrieves the write protection violation status.

Parameters
violation_srcPointer to a variable that will receive the violation source identifier.
Returns
true if a write protection violation has occurred, false otherwise.

◆ DACC_IsReady()

bool DACC_IsReady ( DACC_CHANNEL_NUM channel)

Checks whether the specified DACC channel end-of-conversion is ready.

Parameters
channelDACC channel number (0 or 1).
Returns
true if the channel conversion is complete, false otherwise.

◆ DACC_IsTXReady()

bool DACC_IsTXReady ( DACC_CHANNEL_NUM channel)

Checks whether the specified DACC channel transmit buffer is ready for new data.

Parameters
channelDACC channel number (0 or 1).
Returns
true if the transmit buffer is ready, false otherwise.

◆ DACC_ResetSoftware()

void DACC_ResetSoftware ( void )

Performs a software reset of the DACC peripheral.

Returns
void

◆ DACC_SetAnalogCurrent()

void DACC_SetAnalogCurrent ( DACC_CHANNEL_NUM channel,
DACC_IBCTL_MODE mode )

Sets the analog output current bias (IBCTL) for the specified DACC channel.

Parameters
channelDACC channel number (0 or 1).
modeDACC_IBCTL_mode value selecting the analog current bias level.
Returns
void

◆ DACC_SetCallbackHandler()

void DACC_SetCallbackHandler ( DACC_CALLBACK callback)

Registers the callback function to be invoked from the DACC ISR.

Parameters
callbackPointer to the callback function (NULL to clear).
Returns
void

◆ DACC_SetOSR()

void DACC_SetOSR ( DACC_CHANNEL_NUM channel,
uint32_t osr )

Sets the oversampling ratio (OSR) for the specified DACC channel.

Parameters
channelDACC channel number (0 or 1).
osrOversampling ratio value (refer to DACC_TRIGR register OSR field definitions).
Returns
void

◆ DACC_SetPrescaler()

void DACC_SetPrescaler ( uint8_t prescaler)

Sets the DACC peripheral clock prescaler value.

Parameters
prescaler8-bit prescaler value to divide the peripheral clock.
Returns
void

◆ DACC_WriteData()

void DACC_WriteData ( DACC_CHANNEL_NUM channel,
uint16_t data )

Writes a half-word data value to the specified DACC channel.

Parameters
channelDACC channel number (0 or 1).
data16-bit data value to be converted.
Returns
void

◆ DACC_WriteDataWord()

void DACC_WriteDataWord ( DACC_CHANNEL_NUM channel,
uint16_t data0,
uint16_t data1 )

Writes a word (dual channel data) to the DACC in word transfer mode.

Parameters
channelDACC channel number (0 or 1).
data016-bit data value for channel x.
data116-bit data value for channel x.
Returns
void