STM8L15x Standard Peripherals Drivers: DAC channels configuration

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

DAC channels configuration

DAC channels configuration: trigger, output buffer, data format. More...

Functions

void DAC_Cmd (DAC_Channel_TypeDef DAC_Channel, FunctionalState NewState)
 Enables or disables the specified DAC channel.
void DAC_DeInit (void)
 Deinitializes the DAC peripheral registers to their default reset values.
void DAC_DualSoftwareTriggerCmd (FunctionalState NewState)
 Enables or disables simultaneously the two DAC channels software triggers.
uint16_t DAC_GetDataOutputValue (DAC_Channel_TypeDef DAC_Channel)
 Returns the last data output value of the selected DAC channel.
void DAC_Init (DAC_Channel_TypeDef DAC_Channel, DAC_Trigger_TypeDef DAC_Trigger, DAC_OutputBuffer_TypeDef DAC_OutputBuffer)
 Initializes the DAC according to the specified parameters.
void DAC_SetChannel1Data (DAC_Align_TypeDef DAC_Align, uint16_t DAC_Data)
 Set the specified data holding register value for DAC channel1.
void DAC_SetChannel2Data (DAC_Align_TypeDef DAC_Align, uint16_t DAC_Data)
 Set the specified data holding register value for DAC channel2.
void DAC_SetDualChannelData (DAC_Align_TypeDef DAC_Align, uint16_t DAC_Data2, uint16_t DAC_Data1)
 Set the specified data holding register value for dual channel DAC.
void DAC_SetNoiseWaveLFSR (DAC_Channel_TypeDef DAC_Channel, DAC_LFSRUnmask_TypeDef DAC_LFSRUnmask)
 Select DAC Noise Wave Generation LFSR according to the specified parameters.
void DAC_SetTriangleWaveAmplitude (DAC_Channel_TypeDef DAC_Channel, DAC_TriangleAmplitude_TypeDef DAC_TriangleAmplitude)
 Select DAC Triangle Wave Generation Amplitude according to the specified parameters.
void DAC_SoftwareTriggerCmd (DAC_Channel_TypeDef DAC_Channel, FunctionalState NewState)
 Enables or disables the selected DAC channel software trigger.
void DAC_WaveGenerationCmd (DAC_Channel_TypeDef DAC_Channel, DAC_Wave_TypeDef DAC_Wave, FunctionalState NewState)
 Enables or disables the selected DAC channel wave generation.

Detailed Description

DAC channels configuration: trigger, output buffer, data format.

 ===============================================================================
          DAC channels configuration: trigger, output buffer, data format
 ===============================================================================  


Function Documentation

void DAC_Cmd ( DAC_Channel_TypeDef  DAC_Channel,
FunctionalState  NewState 
)

Enables or disables the specified DAC channel.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
NewState,:new state of the DAC channel. This parameter can be: ENABLE or DISABLE.
Note:
When the DAC channel is enabled the trigger source can no more be modified.
Return values:
None

Definition at line 248 of file stm8l15x_dac.c.

References CR1_Offset, DAC_BASE, DAC_CR1_EN, DISABLE, IS_DAC_CHANNEL, and IS_FUNCTIONAL_STATE.

void DAC_DeInit ( void  )

Deinitializes the DAC peripheral registers to their default reset values.

Parameters:
None
Return values:
None

Definition at line 136 of file stm8l15x_dac.c.

References DAC, DAC_CR1_RESET_VALUE, DAC_CR2_RESET_VALUE, DAC_DHR8_RESET_VALUE, DAC_LDHRH_RESET_VALUE, DAC_LDHRL_RESET_VALUE, DAC_RDHRH_RESET_VALUE, DAC_RDHRL_RESET_VALUE, DAC_SR_RESET_VALUE, and DAC_SWTRIGR_RESET_VALUE.

void DAC_DualSoftwareTriggerCmd ( FunctionalState  NewState)

Enables or disables simultaneously the two DAC channels software triggers.

Parameters:
NewState,:new state of the DAC channels software triggers. This parameter can be: ENABLE or DISABLE.
Return values:
None.

Definition at line 305 of file stm8l15x_dac.c.

References DAC, DAC_SWTRIGR_SWTRIG1, DAC_SWTRIGR_SWTRIG2, DISABLE, and IS_FUNCTIONAL_STATE.

uint16_t DAC_GetDataOutputValue ( DAC_Channel_TypeDef  DAC_Channel)

Returns the last data output value of the selected DAC channel.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
Return values:
Theselected DAC channel data output value.

Definition at line 553 of file stm8l15x_dac.c.

References DAC, DAC_Channel_1, and IS_DAC_CHANNEL.

void DAC_Init ( DAC_Channel_TypeDef  DAC_Channel,
DAC_Trigger_TypeDef  DAC_Trigger,
DAC_OutputBuffer_TypeDef  DAC_OutputBuffer 
)

Initializes the DAC according to the specified parameters.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
DAC_Trigger: the selected DAC trigger. This parameter can be one of the following values:
  • DAC_Trigger_None: DAC trigger None
  • DAC_Trigger_T4_TRGO: DAC trigger TIM4 TRGO
  • DAC_Trigger_T5_TRGO: DAC trigger TIM5 TRGO
  • DAC_Trigger_Ext: DAC trigger External Trigger (PE4)
  • DAC_Trigger_Software: DAC trigger software
DAC_OutputBuffer: the status of DAC load Buffer This parameter can be one of the following values:
  • DAC_OutputBuffer_Enable: DAC output buffer Enabled
  • DAC_OutputBuffer_Disable: DAC output buffer Disabled
Return values:
None

Definition at line 202 of file stm8l15x_dac.c.

References CR1_Offset, DAC_BASE, DAC_CR1_BOFF, DAC_CR1_TEN, DAC_CR1_TSEL, DAC_Trigger_None, IS_DAC_CHANNEL, IS_DAC_OUTPUT_BUFFER_STATE, and IS_DAC_TRIGGER.

void DAC_SetChannel1Data ( DAC_Align_TypeDef  DAC_Align,
uint16_t  DAC_Data 
)

Set the specified data holding register value for DAC channel1.

Parameters:
DAC_Align,:Specifies the data alignment for DAC channel1. This parameter can be one of the following values:
  • DAC_Align_8b_R: 8bit right data alignment selected
  • DAC_Align_12b_L: 12bit left data alignment selected
  • DAC_Align_12b_R: 12bit right data alignment selected
Data: Data to be loaded in the selected data holding register.
Return values:
None.

Definition at line 449 of file stm8l15x_dac.c.

References CH1RDHRH_Offset, DAC, DAC_Align_8b_R, DAC_BASE, IS_DAC_ALIGN, and IS_DAC_DATA_08R.

void DAC_SetChannel2Data ( DAC_Align_TypeDef  DAC_Align,
uint16_t  DAC_Data 
)

Set the specified data holding register value for DAC channel2.

Parameters:
DAC_Align,:Specifies the data alignment for DAC channel2. This parameter can be one of the following values:
  • DAC_Align_8b_R: 8bit right data alignment selected
  • DAC_Align_12b_L: 12bit left data alignment selected
  • DAC_Align_12b_R: 12bit right data alignment selected
Data: Data to be loaded in the selected data holding register.
Return values:
None.

Definition at line 480 of file stm8l15x_dac.c.

References CH2RDHRH_Offset, DAC, DAC_Align_8b_R, DAC_BASE, IS_DAC_ALIGN, and IS_DAC_DATA_08R.

void DAC_SetDualChannelData ( DAC_Align_TypeDef  DAC_Align,
uint16_t  DAC_Data2,
uint16_t  DAC_Data1 
)

Set the specified data holding register value for dual channel DAC.

Parameters:
DAC_Align,:Specifies the data alignment for dual channel DAC. This parameter can be one of the following values:
  • DAC_Align_8b_R: 8bit right data alignment selected
  • DAC_Align_12b_L: 12bit left data alignment selected
  • DAC_Align_12b_R: 12bit right data alignment selected
Data2,:Data for DAC Channel2 to be loaded in the selected data holding register.
Data1,:Data for DAC Channel1 to be loaded in the selected data holding register.
Note:
In dual mode, a unique register access is required to write in both DAC channels at the same time.
Return values:
None.

Definition at line 516 of file stm8l15x_dac.c.

References DAC, DAC_Align_8b_R, DAC_BASE, DCH1RDHRH_Offset, IS_DAC_ALIGN, and IS_DAC_DATA_08R.

void DAC_SetNoiseWaveLFSR ( DAC_Channel_TypeDef  DAC_Channel,
DAC_LFSRUnmask_TypeDef  DAC_LFSRUnmask 
)

Select DAC Noise Wave Generation LFSR according to the specified parameters.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
DAC_LFSRUnmask: the selected unmasked bit. This parameter can be one of the following values:
  • DAC_LFSRUnmask_Bit0: Noise LFSR Unmask 1 LSB
  • DAC_LFSRUnmask_Bits1_0: Noise LFSR Unmask 2 LSB
  • DAC_LFSRUnmask_Bit2_0: Noise LFSR Unmask 3 LSB
  • DAC_LFSRUnmask_Bit3_0: Noise LFSR Unmask 4 LSB
  • DAC_LFSRUnmask_Bit4_0: Noise LFSR Unmask 5 LSB
  • DAC_LFSRUnmask_Bit5_0: Noise LFSR Unmask 6 LSB
  • DAC_LFSRUnmask_Bit6_0: Noise LFSR Unmask 7 LSB
  • DAC_LFSRUnmask_Bit7_0: Noise LFSR Unmask 8 LSB
  • DAC_LFSRUnmask_Bit8_0: Noise LFSR Unmask 9 LSB
  • DAC_LFSRUnmask_Bit9_0: Noise LFSR Unmask 10 LSB
  • DAC_LFSRUnmask_Bit10_0: Noise LFSR Unmask 11 LSB
  • DAC_LFSRUnmask_Bit11_0: Noise LFSR Unmask 12 LSB
Return values:
None

Definition at line 382 of file stm8l15x_dac.c.

References CR2_Offset, DAC_BASE, DAC_CR2_MAMPx, IS_DAC_CHANNEL, and IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE.

void DAC_SetTriangleWaveAmplitude ( DAC_Channel_TypeDef  DAC_Channel,
DAC_TriangleAmplitude_TypeDef  DAC_TriangleAmplitude 
)

Select DAC Triangle Wave Generation Amplitude according to the specified parameters.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
DAC_TriangleAmplitude: the selected Amplitude This parameter can be one of the following values:
  • DAC_TriangleAmplitude_1: Triangle Amplitude = Vref.(1/4096)
  • DAC_TriangleAmplitude_3: Triangle Amplitude = Vref.(3/4096)
  • DAC_TriangleAmplitude_7: Triangle Amplitude = Vref.(7/4096)
  • DAC_TriangleAmplitude_15: Triangle Amplitude = Vref.(15/4096)
  • DAC_TriangleAmplitude_31: Triangle Amplitude = Vref.(31/4096)
  • DAC_TriangleAmplitude_63: Triangle Amplitude = Vref.(63/4096)
  • DAC_TriangleAmplitude_127: Triangle Amplitude = Vref.(127/4096)
  • DAC_TriangleAmplitude_255: Triangle Amplitude = Vref.(255/4096)
  • DAC_TriangleAmplitude_511: Triangle Amplitude = Vref.(511/4096)
  • DAC_TriangleAmplitude_1023: Triangle Amplitude = Vref.(1023/4096)
  • DAC_TriangleAmplitude_2047: Triangle Amplitude = Vref.(2047/4096)
  • DAC_TriangleAmplitude_4095: Triangle Amplitude = Vref.(4095/4096)
Return values:
None

Definition at line 421 of file stm8l15x_dac.c.

References CR2_Offset, DAC_BASE, DAC_CR2_MAMPx, IS_DAC_CHANNEL, and IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE.

void DAC_SoftwareTriggerCmd ( DAC_Channel_TypeDef  DAC_Channel,
FunctionalState  NewState 
)

Enables or disables the selected DAC channel software trigger.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
NewState,:new state of the selected DAC channel software trigger. This parameter can be: ENABLE or DISABLE.
Return values:
None.

Definition at line 280 of file stm8l15x_dac.c.

References DAC, DAC_SWTRIGR_SWTRIG1, DISABLE, IS_DAC_CHANNEL, and IS_FUNCTIONAL_STATE.

void DAC_WaveGenerationCmd ( DAC_Channel_TypeDef  DAC_Channel,
DAC_Wave_TypeDef  DAC_Wave,
FunctionalState  NewState 
)

Enables or disables the selected DAC channel wave generation.

Parameters:
DAC_Channel,:the selected DAC channel. This parameter can be one of the following values:
  • DAC_Channel_1: DAC Channel1 selected
  • DAC_Channel_2: DAC Channel2 selected
DAC_Wave,:Specifies the wave type to enable or disable. This parameter can be one of the following values:
  • DAC_Wave_Noise: noise wave generation
  • DAC_Wave_Triangle: triangle wave generation
NewState,:new state of the selected DAC channel wave generation. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 336 of file stm8l15x_dac.c.

References CR1_Offset, DAC_BASE, DAC_CR1_WAVEN, DISABLE, IS_DAC_CHANNEL, IS_DAC_WAVE, and IS_FUNCTIONAL_STATE.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com