Driver API for DAC (plib_dac.h)
More...
Driver API for DAC (plib_dac.h)
Usage Example
The following example demonstrates typical usage of the DAC peripheral:
#include<stdint.h>
int configure_dac(void)
{
uint16_t initial_dac_value = 0U;
{
}
return 0;
}
void DAC_SetReference(uint8_t refsel_mask)
Set the DAC reference voltage.
#define DAC_OUTPUT_MODE_EXTERNAL
Definition plib_dac.h:70
#define DAC_REFSEL_AVDD
Definition plib_dac.h:62
void DAC_EnableVoltagePump(bool enable)
Enable or disable the DAC voltage pump.
void DAC_DisableRunInStandby(void)
Disable the DAC output buffer in standby sleep mode.
void DAC_EnableDithering(bool enable)
Enable or disable DAC dithering.
void DAC_SetOutputMode(uint8_t mode_mask)
Set the DAC output mode.
void DAC_WriteData(uint16_t data)
Write data to the DAC.
void DAC_Enable(void)
Enable the DAC.
bool DAC_IsReady(void)
Check if the DAC is ready for new data.
◆ DAC_DATA_MSB_MASK
| #define DAC_DATA_MSB_MASK (0x03FFU) |
◆ DAC_DITHER_DISABLE
| #define DAC_DITHER_DISABLE DAC_CTRLB_DITHER(0UL) |
◆ DAC_DITHER_ENABLE
| #define DAC_DITHER_ENABLE DAC_CTRLB_DITHER(1UL) |
◆ DAC_OUTPUT_MODE_ANALOG_COMPARATOR
| #define DAC_OUTPUT_MODE_ANALOG_COMPARATOR DAC_CTRLB_IOEN(1UL) |
◆ DAC_OUTPUT_MODE_EXTERNAL
| #define DAC_OUTPUT_MODE_EXTERNAL DAC_CTRLB_EOEN(1UL) |
◆ DAC_OUTPUT_MODE_INTERNAL_AND_EXTERNAL
| #define DAC_OUTPUT_MODE_INTERNAL_AND_EXTERNAL (DAC_CTRLB_IOEN(1UL) | DAC_CTRLB_EOEN(1UL)) |
Internal and external output enabled
◆ DAC_OUTPUT_MODE_NONE
| #define DAC_OUTPUT_MODE_NONE 0UL |
◆ DAC_REFSEL_AVDD
| #define DAC_REFSEL_AVDD DAC_CTRLB_REFSEL(DAC_CTRLB_REFSEL_AVDD_Val) |
◆ DAC_REFSEL_INTREF
| #define DAC_REFSEL_INTREF DAC_CTRLB_REFSEL(DAC_CTRLB_REFSEL_INTREF_Val) |
◆ DAC_REFSEL_VREFA
| #define DAC_REFSEL_VREFA DAC_CTRLB_REFSEL(DAC_CTRLB_REFSEL_VREFA_Val) |
◆ DAC_CALLBACK
DAC interrupt callback function type.
- Parameters
-
| interruptFlags | Bitmask of interrupt flags (see DAC_INTFLAG_*). |
◆ DAC_INT_FLAG
DAC interrupt/event/flag sources (bitmask).
| Enumerator |
|---|
| DAC_INTFLAG_NONE | |
| DAC_INT_UNDERRUN | Underrun interrupt/event/flag
|
| DAC_INT_EMPTY | Data buffer empty interrupt/event/flag
|
◆ DAC_START_EVENT_EDGE
Edge selection for the DAC Start Event Input.
| Enumerator |
|---|
| DAC_START_EVENT_EDGE_RISING | Detect rising edge on Start Event Input
|
| DAC_START_EVENT_EDGE_FALLING | Detect falling edge on Start Event Input
|
◆ DAC_ClearInterruptFlags()
Clear specified DAC interrupt/event/flags.
- Parameters
-
| flag | Bitwise OR of DAC_INTFLAG_* values. |
- Returns
- None
◆ DAC_Disable()
| void DAC_Disable |
( |
void | | ) |
|
Disable the DAC.
- Parameters
-
- Returns
- None
◆ DAC_DisableInterrupts()
Disable selected DAC interrupts.
- Parameters
-
| flag | Bitwise OR of DAC_INTFLAG_* values. |
- Returns
- None
◆ DAC_DisableRunInStandby()
| void DAC_DisableRunInStandby |
( |
void | | ) |
|
Disable the DAC output buffer in standby sleep mode.
- Parameters
-
- Returns
- None
◆ DAC_Enable()
Enable the DAC.
- Parameters
-
- Returns
- None
◆ DAC_EnableDataBufferEmptyEvent()
| void DAC_EnableDataBufferEmptyEvent |
( |
bool | enable | ) |
|
Enable or disable the Data Buffer Empty Event Output.
- Parameters
-
| enable | true to enable, false to disable. |
- Returns
- None
◆ DAC_EnableDithering()
| void DAC_EnableDithering |
( |
bool | enable | ) |
|
Enable or disable DAC dithering.
- Parameters
-
| enable | true to enable, false to disable. |
- Returns
- None
◆ DAC_EnableInterrupts()
Enable selected DAC interrupts.
- Parameters
-
| flag | Bitwise OR of DAC_INTFLAG_* values. |
- Returns
- None
◆ DAC_EnableRunInStandby()
| void DAC_EnableRunInStandby |
( |
void | | ) |
|
Enable the DAC output buffer in standby sleep mode.
- Parameters
-
- Returns
- None
◆ DAC_EnableStartConversionOnEvent()
| void DAC_EnableStartConversionOnEvent |
( |
bool | enable | ) |
|
Enable or disable Start Conversion on Event.
- Parameters
-
| enable | true to enable, false to disable. |
- Returns
- None
◆ DAC_EnableVoltagePump()
| void DAC_EnableVoltagePump |
( |
bool | enable | ) |
|
Enable or disable the DAC voltage pump.
- Parameters
-
| enable | true to enable, false to disable. |
- Returns
- None
◆ DAC_GetResolution()
| uint8_t DAC_GetResolution |
( |
void | | ) |
|
Get the current DAC resolution (10 or 14 bits).
- Parameters
-
- Returns
- 14 if DITHER is enabled, 10 if disabled.
◆ DAC_IsInterruptFlagsSet()
Check if any of the specified DAC interrupt/event/flags are set.
- Parameters
-
| flag | Bitwise OR of DAC_INTFLAG_* values. |
- Returns
- true if any specified flag is set, false otherwise.
◆ DAC_IsReady()
| bool DAC_IsReady |
( |
void | | ) |
|
Check if the DAC is ready for new data.
- Parameters
-
- Returns
- true if ready, false otherwise.
◆ DAC_RegisterCallback()
Register a callback function for DAC interrupts.
The callback will be called from the DAC interrupt handler when any enabled DAC interrupt occurs. The callback receives the set interrupt flags and the
- Parameters
-
| callback | Pointer to the callback function. |
- Returns
- None
◆ DAC_ResetSoftware()
| void DAC_ResetSoftware |
( |
void | | ) |
|
Perform a software reset of the DAC.
- Parameters
-
- Returns
- None
◆ DAC_SetOutputMode()
| void DAC_SetOutputMode |
( |
uint8_t | mode_mask | ) |
|
Set the DAC output mode.
- Parameters
-
| mode_mask | Output mode mask (use DAC_OUTPUT_MODE_* macros). |
- Returns
- None
◆ DAC_SetReference()
| void DAC_SetReference |
( |
uint8_t | refsel_mask | ) |
|
Set the DAC reference voltage.
- Parameters
-
| refsel_mask | Reference selection mask (use DAC_REFSEL_* macros). |
- Returns
- None
◆ DAC_SetStartEventEdge()
Set the edge detection for the DAC Start Event Input.
- Parameters
-
| edge | Edge selection (use DAC_START_EVENT_EDGE_RISING or DAC_START_EVENT_EDGE_FALLING). |
◆ DAC_WriteData()
| void DAC_WriteData |
( |
uint16_t | data | ) |
|
Write data to the DAC.
- Parameters
-
| data | 10-bit data value to write. |
- Returns
- None