XMC Peripheral Library for XMC4000 Family: DAC

XMC Peripheral Library for XMC4000 Family

XMC Peripheral Library for XMC4000 Family  2.1.16

Data Structures

struct  XMC_DAC_CH_CONFIG_t
 
struct  XMC_DAC_t
 

Macros

#define XMC_DAC0   ((XMC_DAC_t *)DAC_BASE)
 
#define XMC_DAC_NO_CHANNELS   (2U)
 
#define XMC_DAC_PATTERN_RECTANGLE   {31U, 31U, 31U, 31U, 31U, 31U, 31U, 31U, 31U}
 
#define XMC_DAC_PATTERN_SINE   {0U, 6U, 12U, 17U, 22U, 26U, 29U, 30U, 31U}
 
#define XMC_DAC_PATTERN_TRIANGLE   {0U, 4U, 8U, 12U, 16U, 19U, 23U, 27U, 31U}
 
#define XMC_DAC_SAMPLES_PER_PERIOD   (32U)
 

Enumerations

Functions

void XMC_DAC_CH_DisableEvent (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_DisableOutput (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_DisableOutputNegation (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_DisablePatternSignOutput (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_EnableEvent (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_EnableOutput (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_EnableOutputNegation (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_EnablePatternSignOutput (XMC_DAC_t *const dac, const uint8_t channel)
 
XMC_DAC_CH_OUTPUT_SCALE_t XMC_DAC_CH_GetOutputScale (XMC_DAC_t *const dac, const uint8_t channel)
 
uint16_t XMC_DAC_CH_GetRampStart (XMC_DAC_t *const dac, const uint8_t channel)
 
uint16_t XMC_DAC_CH_GetRampStop (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_Init (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_CONFIG_t *const config)
 
bool XMC_DAC_CH_IsFifoEmpty (const XMC_DAC_t *const dac, const uint8_t channel)
 
bool XMC_DAC_CH_IsFifoFull (const XMC_DAC_t *const dac, const uint8_t channel)
 
bool XMC_DAC_CH_IsOutputEnabled (const XMC_DAC_t *const dac, const uint8_t channel)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetFrequency (XMC_DAC_t *const dac, const uint8_t channel, const uint32_t frequency)
 
void XMC_DAC_CH_SetMode (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_MODE_t mode)
 
void XMC_DAC_CH_SetOutputOffset (XMC_DAC_t *const dac, const uint8_t channel, const uint8_t offset)
 
void XMC_DAC_CH_SetOutputScale (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_OUTPUT_SCALE_t scale)
 
void XMC_DAC_CH_SetPattern (XMC_DAC_t *const dac, const uint8_t channel, const uint8_t *const pattern)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetPatternFrequency (XMC_DAC_t *const dac, const uint8_t channel, const uint32_t frequency)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetRampFrequency (XMC_DAC_t *const dac, const uint8_t channel, const uint32_t frequency)
 
void XMC_DAC_CH_SetRampStart (XMC_DAC_t *const dac, const uint8_t channel, const uint16_t start)
 
void XMC_DAC_CH_SetRampStop (XMC_DAC_t *const dac, const uint8_t channel, const uint16_t stop)
 
void XMC_DAC_CH_SetSignedDataType (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_SetTrigger (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_TRIGGER_t trigger)
 
void XMC_DAC_CH_SetUnsignedDataType (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_SoftwareTrigger (XMC_DAC_t *const dac, const uint8_t channel)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartDataMode (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_TRIGGER_t trigger, const uint32_t frequency)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartNoiseMode (XMC_DAC_t *const dac, const uint8_t channel, const XMC_DAC_CH_TRIGGER_t trigger, const uint32_t frequency)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartPatternMode (XMC_DAC_t *const dac, const uint8_t channel, const uint8_t *const pattern, const XMC_DAC_CH_PATTERN_SIGN_OUTPUT_t sign_output, const XMC_DAC_CH_TRIGGER_t trigger, const uint32_t frequency)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartRampMode (XMC_DAC_t *const dac, const uint8_t channel, const uint16_t start, const uint16_t stop, const XMC_DAC_CH_TRIGGER_t trigger, const uint32_t frequency)
 
XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartSingleValueMode (XMC_DAC_t *const dac, const uint8_t channel)
 
void XMC_DAC_CH_Write (XMC_DAC_t *const dac, const uint8_t channel, const uint16_t data)
 
void XMC_DAC_Disable (XMC_DAC_t *const dac)
 
void XMC_DAC_DisableSimultaneousDataMode (XMC_DAC_t *const dac)
 
void XMC_DAC_Enable (XMC_DAC_t *const dac)
 
void XMC_DAC_EnableSimultaneousDataMode (XMC_DAC_t *const dac)
 
bool XMC_DAC_IsEnabled (const XMC_DAC_t *const dac)
 
void XMC_DAC_SimultaneousWrite (XMC_DAC_t *const dac, const uint16_t data0, const uint16_t data1)
 

Detailed Description

DAC driver uses DAC peripheral to convert digital value to analog value. XMC4000 microcontroller family has two DAC channels of 12-bit resolution and maximum conversion rate of 2MHz with full accuracy and 5MHz with reduced accuracy. It consists of inbuilt pattern generator, ramp generator and noise generator modes. Additionally, waveforms can be generated by configuring data registers in single value mode and in data mode. It has DMA handling capability to generate custom waveforms in data mode without CPU intervention.

DAC driver features:

  1. Configuration structure XMC_DAC_CH_CONFIG_t and initialization function XMC_DAC_CH_Init() to initialize DAC and configure channel settings
  2. Pattern Generator Mode:
  3. Single Value Mode:
  4. Data Mode:
  5. Ramp Mode:
  6. Noise Mode:
  7. Allows to change the scale, offset dynamically using XMC_DAC_CH_SetOutputScale() and XMC_DAC_CH_SetOutputOffset() respectively
  8. Allows to select one of the eight possible trigger sources using XMC_DAC_CH_SetTrigger()
  9. 2 DAC channels can be used in synchronization in single value mode and data mode to generate two analog outputs in sync. XMC_DAC_EnableSimultaneousDataMode()

Macro Definition Documentation

#define XMC_DAC0   ((XMC_DAC_t *)DAC_BASE)

DAC module register base

#define XMC_DAC_NO_CHANNELS   (2U)

DAC maximum channels

#define XMC_DAC_PATTERN_RECTANGLE   {31U, 31U, 31U, 31U, 31U, 31U, 31U, 31U, 31U}

First quarter Rectangle waveform samples

#define XMC_DAC_PATTERN_SINE   {0U, 6U, 12U, 17U, 22U, 26U, 29U, 30U, 31U}

First quarter Sine waveform samples

#define XMC_DAC_PATTERN_TRIANGLE   {0U, 4U, 8U, 12U, 16U, 19U, 23U, 27U, 31U}

First quarter Triangle waveform samples

#define XMC_DAC_SAMPLES_PER_PERIOD   (32U)

DAC samples per period in pattern mode

Enumeration Type Documentation

Data type of the input data

Enumerator
XMC_DAC_CH_DATA_TYPE_UNSIGNED 

input data is unsigned

XMC_DAC_CH_DATA_TYPE_SIGNED 

input data is signed

Operating modes of DAC

Enumerator
XMC_DAC_CH_MODE_IDLE 

DAC is disabled

XMC_DAC_CH_MODE_SINGLE 

Single value mode - single data value is updated and maintained

XMC_DAC_CH_MODE_DATA 

Data mode - continuous data processing

XMC_DAC_CH_MODE_PATTERN 

Pattern mode - inbuilt pattern waveform generation - Sine, Triangle, Rectangle

XMC_DAC_CH_MODE_NOISE 

Noise mode - pseudo-random noise generation

XMC_DAC_CH_MODE_RAMP 

Ramp mode - ramp generation

Negation of input data (applicable only for XMC44 device)

Enumerator
XMC_DAC_CH_OUTPUT_NEGATION_DISABLED 

XMC_DAC_CH_OUTPUT_NEGATION_DISABLED

XMC_DAC_CH_OUTPUT_NEGATION_ENABLED 

XMC_DAC_CH_OUTPUT_NEGATION_ENABLED

Scaling of the input data

Enumerator
XMC_DAC_CH_OUTPUT_SCALE_NONE 

No scaling

XMC_DAC_CH_OUTPUT_SCALE_MUL_2 

multiplied by 2

XMC_DAC_CH_OUTPUT_SCALE_MUL_4 

multiplied by 4

XMC_DAC_CH_OUTPUT_SCALE_MUL_8 

multiplied by 8

XMC_DAC_CH_OUTPUT_SCALE_MUL_16 

multiplied by 16

XMC_DAC_CH_OUTPUT_SCALE_MUL_32 

multiplied by 32

XMC_DAC_CH_OUTPUT_SCALE_MUL_64 

multiplied by 64

XMC_DAC_CH_OUTPUT_SCALE_MUL_128 

multiplied by 128

XMC_DAC_CH_OUTPUT_SCALE_DIV_2 

divided by 2

XMC_DAC_CH_OUTPUT_SCALE_DIV_4 

divided by 4

XMC_DAC_CH_OUTPUT_SCALE_DIV_8 

divided by 8

XMC_DAC_CH_OUTPUT_SCALE_DIV_16 

divided by 16

XMC_DAC_CH_OUTPUT_SCALE_DIV_32 

divided by 32

XMC_DAC_CH_OUTPUT_SCALE_DIV_64 

divided by 64

XMC_DAC_CH_OUTPUT_SCALE_DIV_128 

divided by 128

Output sign signal for the Pattern Generation Mode

Enumerator
XMC_DAC_CH_PATTERN_SIGN_OUTPUT_DISABLED 

Sign output signal generation is disabled

XMC_DAC_CH_PATTERN_SIGN_OUTPUT_ENABLED 

Sign output signal generation is enabled

Return types of the API's

Enumerator
XMC_DAC_CH_STATUS_OK 

Status is ok, no error detected

XMC_DAC_CH_STATUS_ERROR 

Error detected

XMC_DAC_CH_STATUS_BUSY 

DAC is busy

XMC_DAC_CH_STATUS_ERROR_FREQ2LOW 

Frequency can't be configured. Frequency is to low.

XMC_DAC_CH_STATUS_ERROR_FREQ2HIGH 

Frequency can't be configured. Frequency is to high.

Trigger sources for the data update

Enumerator
XMC_DAC_CH_TRIGGER_INTERNAL 

Internal trigger as per frequency divider value

XMC_DAC_CH_TRIGGER_EXTERNAL_CCU80_SR1 

External trigger from CCU80 Interrupt SR1

XMC_DAC_CH_TRIGGER_EXTERNAL_CCU40_SR1 

External trigger from CCU40 Interrupt SR1

XMC_DAC_CH_TRIGGER_EXTERNAL_CCU41_SR1 

External trigger from CCU41 Interrupt SR1

XMC_DAC_CH_TRIGGER_EXTERNAL_P2_9 

External trigger from pin 2.9

XMC_DAC_CH_TRIGGER_EXTERNAL_P2_8 

External trigger from pin 2.8

XMC_DAC_CH_TRIGGER_EXTERNAL_U0C0_DX1INS 

External trigger from USIC-0 DX1 Input Signal

XMC_DAC_CH_TRIGGER_EXTERNAL_U1C0_DX1INS 

External trigger from USIC-1 DX1 Input Signal

XMC_DAC_CH_TRIGGER_SOFTWARE 

Software trigger

Function Documentation

void XMC_DAC_CH_DisableEvent ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Disables service request by clearing SREN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Related APIs:
XMC_DAC_CH_EnableEvent()

void XMC_DAC_CH_DisableOutput ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Channel channel output is disabled by clearing the ANAEN bit of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
A call to this API stops driving the converted digital input to its output.
Related APIs:
XMC_DAC_CH_EnableOutput(), XMC_DAC_CH_IsOutputEnabled()


void XMC_DAC_CH_DisableOutputNegation ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Description:
Disables output negation.
Negation is disabled by clearing NEGATE bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Note:
Negation feature is not applicable for XMC45 devices. Calling this API in XMC45 devices doesn't have any effect.
Related APIs:
XMC_DAC_CH_EnableOutputNegation()


void XMC_DAC_CH_DisablePatternSignOutput ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Disables output sign information for Pattern Mode.
Sign output is disabled by clearing SIGNEN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Note:
Call this API if the channel is set to Pattern mode.
Related APIs:
XMC_DAC_CH_StartPatternMode(), XMC_DAC_CH_EnablePatternSignOutput()


void XMC_DAC_CH_EnableEvent ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Enables service request by setting SREN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1). Trigger signal is generated upon conversion of each data.
Note:
The service request signal can be connected to NVIC, DMA.
Related APIs:
XMC_DAC_CH_DisableEvent()


void XMC_DAC_CH_EnableOutput ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Channel channel output is enabled by setting the ANAEN bit of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
Note:
tSTARTUP time for DAC analog output starts after the ANAEN bit is set to one. After the expiry of the startup time the default value is driven to DAC output and a new value can be written.
Related APIs:
XMC_DAC_CH_DisableOutput(), XMC_DAC_CH_IsOutputEnabled()


void XMC_DAC_CH_EnableOutputNegation ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Description:
Enables output negation.
By negating the DAC value is converted to its two's complement values. Can be used in Ramp mode to generate negative ramp. Negation in enabled by setting NEGATE bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Note:
Negation feature is not applicable for XMC45 devices. Calling this API in XMC45 devices doesn't have any effect.
Related APIs:
XMC_DAC_CH_DisableOutputNegation(), XMC_DAC_CH_StartRampMode()


void XMC_DAC_CH_EnablePatternSignOutput ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Enables the output sign information for Pattern Mode.
Sign output is enabled by setting SIGNEN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Note:
Call this API if the channel is set to Pattern mode.
Related APIs:
XMC_DAC_CH_StartPatternMode(), XMC_DAC_CH_DisablePatternSignOutput()


XMC_DAC_CH_OUTPUT_SCALE_t XMC_DAC_CH_GetOutputScale ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
XMC_DAC_CH_OUTPUT_SCALE_t
Description:
Returns scaling information for the data. The input data could be either up-scaled (multiplied), down-scaled (divided) or without scaling (as is).
Scaling factor is determined by reading bit-fields MULDIV and SCALE of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
Related APIs:
XMC_DAC_CH_SetOutputScale()


uint16_t XMC_DAC_CH_GetRampStart ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
uint16_t
Description:
Gets the ramp start value by reading DATA0 bit-field of DAC0DATA register (for channel 0) / DATA1 bit-field of DAC1DATA register (for channel 1). If the ramp counter reaches its stop value, it restarts from the start value with the next trigger pulse.
Note:
Call this API if the channel is set to Ramp mode.
Related APIs:
XMC_DAC_CH_SetRampStart(), XMC_DAC_CH_StartRampMode(), XMC_DAC_CH_GetRampStop(), XMC_DAC_CH_SetRampStop()


uint16_t XMC_DAC_CH_GetRampStop ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
uint16_t
Description:
Gets the ramp stop value by reading DATA0 bit-field of DAC01DATA register (for channel 0) / DATA1 bit-field of DAC01DATA register (for channel 1). If the ramp counter reaches its stop value, it restarts from the start value with the next trigger pulse.
Note:
Call this API if the channel is set to Ramp mode.
Related APIs:
XMC_DAC_CH_SetRampStop(), XMC_DAC_CH_StartRampMode(), XMC_DAC_CH_GetRampStart()


void XMC_DAC_CH_Init ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_CONFIG_t *const  config 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
configPointer to the DAC channel configuration structure
Returns
None
Description:
Initialises and configures the DAC channel with the configuration date pointed by config.
DAC channel is initialised by configuring the registers DAC0CFG0 and DAC0CFG1 registers (for channel 0) / DAC1CFG0 and DAC1CFG1 registers (for channel 1). It enables the channel output by calling XMC_DAC_CH_EnableOutput().
bool XMC_DAC_CH_IsFifoEmpty ( const XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
bool
true - if FIFO is empty
false - if FIFO is not empty
Description:
Returns FIFO status.
FIFIO empty status is determined by reading FIFOEMP bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Related APIs:
XMC_DAC_CH_IsFifoFull()


bool XMC_DAC_CH_IsFifoFull ( const XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
bool
true - if FIFO is full
false - if FIFO is not full
Description:
Returns FIFO status.
FIFIO full status is determined by reading FIFOFUL bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Related APIs:
XMC_DAC_CH_IsFifoEmpty()


bool XMC_DAC_CH_IsOutputEnabled ( const XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
bool
true - if analog output is enabled
false - if analog output is disabled
Description:
Returns the status of DAC analog output.
Channel channel output enabled or disabled is determined by reading the ANAEN bit of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
Related APIs:
XMC_DAC_CH_EnableOutput(), XMC_DAC_CH_DisableOutput()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetFrequency ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
frequencyWaveform frequency in [Hz]
Returns
XMC_DAC_CH_STATUS_t
Description:
Sets the frequency of DAC channel.
The value frequency acts as clock divider. The smallest frequency divider value is 16. A valid frequency value should be within the range XMC_DAC_MIN_FREQ_DIVIDER to XMC_DAC_MAX_FREQ_DIVIDER. A value outside this range is considered as in valid and API returns error. Frequency frequency is configured by setting FREQ bit-field of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1).
Note:
Call this API only for Single value mode, Data mode and Noise mode. Call XMC_DAC_CH_SetRampFrequency() in case of Ramp mode and XMC_DAC_CH_SetPatternFrequency() in case of Pattern mode.
Related APIs:
XMC_DAC_CH_SetRampFrequency(), XMC_DAC_CH_SetPatternFrequency()


void XMC_DAC_CH_SetMode ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_MODE_t  mode 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
modeDAC operation mode
Returns
None
Description:
Sets the operating mode for the channel by setting the MODE bit-field of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1). Different modes of DAC operation are defined by enum XMC_DAC_CH_MODE_t.
void XMC_DAC_CH_SetOutputOffset ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint8_t  offset 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
offset
Returns
None
Description:
Sets the offset value.
Offset range:0 - 255
interpreted as : -128 to 127 (twos complement) in signed mode and 0 to 255 in unsigned mode.
Note:
Scaling can be applied to the output data after adding the offset value.
Channel channel offset value is loaded to the bit-field DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
Related APIs:
XMC_DAC_CH_SetOutputScale()


void XMC_DAC_CH_SetOutputScale ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_OUTPUT_SCALE_t  scale 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
scaleInput data scaling
Returns
None
Description:
Data of the channel is scaled.
The data can either be scaled up-scaled (multiplied), down-scaled (divided) or no scaling (as is) based on the value of scale. Scaling is configured by setting bit-fields MULDIV and SCALE of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1).
Related APIs:
XMC_DAC_CH_GetOutputScale()


void XMC_DAC_CH_SetPattern ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint8_t *const  pattern 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
patternPointer to the data table
Returns
None
Description:
The data for the Pattern mode is written to the DAC0PATL and DAC0PATH registers. The API is called by XMC_DAC_CH_StartPatternMode().
Note:
Call this API if the channel is set to Pattern mode.
Related APIs:
XMC_DAC_CH_EnablePatternSignOutput(), XMC_DAC_CH_DisablePatternSignOutput()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetPatternFrequency ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
frequencyin [Hz]
Returns
XMC_DAC_CH_STATUS_t
Description:
Sets the frequency of DAC channel by calling XMC_DAC_CH_SetFrequency().
For the Pattern mode, the frequency of operation depends on the total number of sample points XMC_DAC_SAMPLES_PER_PERIOD. Frequency frequency is multiplied by the total number of sample points, so that each trigger instance converts all the sample points of the pattern.
Note:
Call this API only if the channel is set to Pattern mode.
Related APIs:
XMC_DAC_CH_StartPatternMode()


< DAC samples per period in pattern mode

XMC_DAC_CH_STATUS_t XMC_DAC_CH_SetRampFrequency ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
frequency[Hz]
Returns
XMC_DAC_CH_STATUS_t
Description:
Sets the frequency of DAC channel by calling XMC_DAC_CH_SetFrequency().
For the Ramp mode, the frequency of operation depends on the total number of sample points (stop - start). Frequency frequency is multiplied by the total number of sample points, so that each trigger instance converts all the sample points of ramp.
Note:
Call this API only if the channel is set to Ramp mode.
Related APIs:
XMC_DAC_CH_StartRampMode()


void XMC_DAC_CH_SetRampStart ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint16_t  start 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
startRamp start point [0-4095]
Returns
None
Description:
Sets the ramp start value by writing to the register DAC0DATA (for channel 0) or DAC1DATA (for channel 1). If the ramp counter reaches its stop value, it restarts from the start value with the next trigger pulse. Ensure start value is lower than the stop value.
Note:
Call this API if the channel is set to Ramp mode. Start value is a 12 bit data.
Related APIs:
XMC_DAC_CH_GetRampStart(), XMC_DAC_CH_GetRampStop(), XMC_DAC_CH_SetRampStop()


void XMC_DAC_CH_SetRampStop ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint16_t  stop 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
stopRamp stop point [0-4095]
Returns
None
Description:
Sets the ramp stop value by writing to the bit-field DATA0 (for channel 0) or DATA1 (for channel 1) of DAC01DATA register. If the ramp counter reaches its stop value, it restarts from the start value with the next trigger pulse. Ensure stop value is higher than the start value.
Note:
Call this API if the channel is set to Ramp mode. Stop value is a 12 bit data.
Related APIs:
XMC_DAC_CH_GetRampStop(), XMC_DAC_CH_SetRampStart()


void XMC_DAC_CH_SetSignedDataType ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Sets the channel's data to signed type by setting SIGN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1). The data for the conversion would then be treated as signed data type.
Note:
Offset and scaling can be applied to the data by calling XMC_DAC_CH_SetOutputOffset(), XMC_DAC_CH_SetOutputScale().
Related APIs:
XMC_DAC_CH_SetUnsignedDataType()


void XMC_DAC_CH_SetTrigger ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_TRIGGER_t  trigger 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
triggerTrigger source
Returns
None
Description:
Selects the trigger source for the channel by configuring the bits TRIGSEL & TRIGMOD of CFG register.
Channel channel trigger source is selected by TRIGSEL bit-field of DAC0CFG1 register (for channel 0) / DAC1CFG1 register(for channel 1).
void XMC_DAC_CH_SetUnsignedDataType ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Sets the channel's data to unsigned type by clearing SIGN bit of DAC0CFG0 register (for channel 0) / DAC1CFG0 register (for channel 1). The data for the conversion would then be treated as unsigned data type.
Note:
Offset and scaling can be applied to the data by calling XMC_DAC_CH_SetOutputOffset(), XMC_DAC_CH_SetOutputScale().
Related APIs:
XMC_DAC_CH_SetSignedDataType()


void XMC_DAC_CH_SoftwareTrigger ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
A call to this API generates a trigger pulse by setting SWTRIG bit of DAC0CFG1 register (for channel 0) / DAC1CFG1 register (for channel 1), provided the TRIGMOD bit of CFG register is set to XMC_DAC_CH_TRIGGER_SOFTWARE.
Note:
If the channel is set to simultaneous data mode, SWTRIG bit of channel 1 is not valid. Only SWTRIG bit of channel 0 is used for channel 1.
Related APIs:
XMC_DAC_CH_SetTrigger(), XMC_DAC_CH_EnableEvent()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartDataMode ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_TRIGGER_t  trigger,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
triggerData points update trigger
frequencyWaveform frequency [Hz]
Returns
XMC_DAC_CH_STATUS_t status
Description:
Sets the channel to Data mode. Trigger and frequency are configured.
Note:
Call XMC_DAC_CH_Write() API to write the data. Call XMC_DAC_EnableSimultaneousDataMode() to switch to Simultaneous data mode.
Related APIs:
XMC_DAC_CH_Init(), XMC_DAC_CH_Write(), XMC_DAC_EnableSimultaneousDataMode()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartNoiseMode ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const XMC_DAC_CH_TRIGGER_t  trigger,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
triggerData points update trigger
frequencyWaveform frequency in [Hz]
Returns
XMC_DAC_CH_STATUS_t status
Description:
Sets the channel to Noise mode. Trigger and frequency are configured. On a trigger the DAC starts converting and drives to channel output.
Related APIs:
XMC_DAC_CH_Init()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartPatternMode ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint8_t *const  pattern,
const XMC_DAC_CH_PATTERN_SIGN_OUTPUT_t  sign_output,
const XMC_DAC_CH_TRIGGER_t  trigger,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
patternData table of a pattern
sign_outputSign information of the waveform
triggerData points update trigger
frequencyWaveform frequency in [Hz]
Returns
XMC_DAC_CH_STATUS_t status
Description:
Sets the channel to Pattern mode. Trigger, frequency, sign output and data are configured. On a trigger, the pattern values are converted and driven to channel output.
Related APIs:
XMC_DAC_CH_Init(), XMC_DAC_CH_DisablePatternSignOutput()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartRampMode ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint16_t  start,
const uint16_t  stop,
const XMC_DAC_CH_TRIGGER_t  trigger,
const uint32_t  frequency 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
startStart point of the ramp [0-4095]
stopStop point of the ramp [0-4095]
triggerData points update trigger
frequencyRamp frequency in [Hz]
Returns
XMC_DAC_CH_STATUS_t status
Description:
Sets the channel to Ramp mode. Trigger, frequency, start and stop values are configured. On a trigger ramp values are converted and driven to channel output. Start and stop have the range of [0-4095]. Stop should be equal or greater than start.
Note:
If the ramp counter reaches its stop value, it restarts from the start value with the next trigger pulse.
Related APIs:
XMC_DAC_CH_Init(), XMC_DAC_CH_GetRampStart(), XMC_DAC_CH_GetRampStop()


XMC_DAC_CH_STATUS_t XMC_DAC_CH_StartSingleValueMode ( XMC_DAC_t *const  dac,
const uint8_t  channel 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
Returns
None
Description:
Sets the channel to Single Value Mode by calling XMC_DAC_CH_SetMode().
Note:
Call XMC_DAC_CH_Write() API to write the data.
Related APIs:
XMC_DAC_CH_Write()


void XMC_DAC_CH_Write ( XMC_DAC_t *const  dac,
const uint8_t  channel,
const uint16_t  data 
)
Parameters
dacPointer to an instance of DAC module
channelDAC channel number
dataData to be written [0-4095]
Returns
None
Description:
Writes the data to the channel's DATA register.
The data is then converted and driven to the output. If the trigger is set, On a trigger event the data in DATA register is converted and driven to channel output. Data data is written to the channel by loading data to DATA0 bit-field of DAC0DATA (for channel 0) / DATA1 bit-field of DAC1DATA register (for channel 1). data has the range of [0-4095].
Note:
The API can be used for Single Value Mode, Data Mode (Individual) & Ramp Mode. Call XMC_DAC_CH_EnableOutput() API to enable analog output.
Related APIs:
XMC_DAC_CH_StartSingleValueMode(), XMC_DAC_CH_StartDataMode(), XMC_DAC_CH_StartRampMode()


void XMC_DAC_Disable ( XMC_DAC_t *const  dac)
Parameters
dacPointer to an instance of DAC module
Returns
None
Description:
Disables DAC clock and resets DAC.
DAC clock is disabled by setting DAC bit of CGATSET1 register. DAC is reset by setting DACRS bit of PRSET1 register.
Related APIs:
XMC_DAC_IsEnabled(), XMC_DAC_Enable()


void XMC_DAC_DisableSimultaneousDataMode ( XMC_DAC_t *const  dac)
Parameters
dacPointer to an instance of DAC module
Returns
None
Description:
DAC switches to independent data mode from simultaneous Data mode.
Independent data mode is the default data mode. Simultaneous data mode is disabled by clearing DATMOD bit of DAC0CFG1 register.
Related APIs:
XMC_DAC_CH_StartDataMode(), XMC_DAC_EnableSimultaneousDataMode()


void XMC_DAC_Enable ( XMC_DAC_t *const  dac)
Parameters
dacPointer to an instance of DAC module
Returns
None
Description:
Enables DAC clock and releases DAC reset.
Enabling DAC is the first step of DAC initialisation. This API is called by XMC_DAC_CH_Init(). DAC clock is enabled by setting DAC bit of CGATCLR1 register. DAC reset is released by setting DACRS bit of PRCLR1 register.
Related APIs:
XMC_DAC_IsEnabled(), XMC_DAC_Disable(), XMC_DAC_CH_Init()


void XMC_DAC_EnableSimultaneousDataMode ( XMC_DAC_t *const  dac)
Parameters
dacPointer to an instance of DAC module
Returns
None
Description:
DAC switches to Simultaneous data mode from Independent data mode.
Independent data mode is the default data mode. Simultaneous data mode is enabled by setting DATMOD bit of DAC0CFG1 register.
Note:
Set channel 0 and channel 1 to Data mode before calling this API.
Related APIs:
XMC_DAC_CH_StartSingleValueMode(), XMC_DAC_CH_StartDataMode(), XMC_DAC_SimultaneousWrite(), XMC_DAC_DisableSimultaneousDataMode()


bool XMC_DAC_IsEnabled ( const XMC_DAC_t *const  dac)
Parameters
dacPointer to an instance of DAC module
Returns
bool
true - if DAC is enabled
false - if DAC is disabled
Description:
Returns the state of the DAC.
DAC enabled status is determined by referring to DACRS bit of PRSTAT1 register.
Related APIs:
XMC_DAC_Enable(), XMC_DAC_Disable()


void XMC_DAC_SimultaneousWrite ( XMC_DAC_t *const  dac,
const uint16_t  data0,
const uint16_t  data1 
)
Parameters
dacPointer to an instance of DAC module
data0Data for DAC channel 0 [0-4095]
data1Data for DAC channel 1 [0-4095]
Returns
None
Description:
The data (data0 & data1) to be converted by channel 0 & channel 1 are updated to DATA1 bit-fields of DAC01DATA register. data0 and data1 have the range of [0-4095].
Note:
Channel 0 and Channel 1 should be set to simultaneous data mode before calling this API.
Related APIs:
XMC_DAC_EnableSimultaneousDataMode()


Generated on Mon Aug 7 2017 11:33:57 for XMC Peripheral Library for XMC4000 Family by   doxygen 1.8.11