Digital-to-analog converter (DAC)
Digital to Analog conversion can be non-triggered using DAC_Trigger_None and
DAC_OUT1/DAC_OUT2 is available once writing to DHRx register using
DAC_SetChannel1Data()/DAC_SetChannel2Data.
Digital to Analog conversion can be triggered by:
1.
External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9. The
used pin (GPIOx_Pin9) must be configured in input mode.
2.
Timers TRGO: TIM2, TIM8/TIM3, TIM4, TIM6, TIM7, and TIM15
(DAC_Trigger_T2_TRGO, DAC_Trigger_T4_TRGO...) The timer TRGO event should
be selected using TIM_SelectOutputTrigger()
3.
Software using DAC_Trigger_Software
Each DAC channel integrates an output buffer that can be used to reduce the output
impedance, and to drive external loads directly without having to add an external
operational amplifier. To enable, the output buffer use
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
Refer to the device datasheet for more details about output impedance value with and
without output buffer.
Both DAC channels can be used to generate:
Noise wave using DAC_WaveGeneration_Noise
Triangle wave using DAC_WaveGeneration_Triangle
Wave generation can be disabled using DAC_WaveGeneration_None
The DAC data format can be:
8-bit right alignment using DAC_Align_8b_R
12-bit left alignment using DAC_Align_12b_L
12-bit right alignment using DAC_Align_12b_R
The analog output voltage on each DAC channel pin is determined by the following
equation:
DAC_OUTx = VREF+ * DOR / 4095 with DOR is the Data Output Register. VREF+ is
the input voltage reference (refer to the device datasheet) e.g. To set DAC_OUT1 to
0.7V, use DAC_SetChannel1Data(DAC_Align_12b_R, 868); Assuming that VREF+ =
3.3, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
A DMA request can be generated when an external trigger (but not a software trigger)
occurs if DMA2 requests are enabled using DAC_DMACmd(); DMA requests are mapped
as following:
DAC channel1 is mapped on DMA2 channel3 which must be already configured.
DAC channel2 is mapped on DMA2 channel4 which must be already configured.
7.2.2
How to use this driver
162/584
To trigger DAC conversions by TIM3 instead of TIM8 follow this sequence:
Enable SYSCFG APB clock by calling
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
Select DAC_Trigger_T3_TRGO when calling DAC_Init()
Remap the DAC trigger from TIM8 to TIM3 by calling
SYSCFG_TriggerRemapConfig(SYSCFG_TriggerRemap_DACTIM3,
ENABLE)
DocID023800 Rev 1
UM1581
Need help?
Do you have a question about the STM32F31xx and is the answer not in the manual?
Questions and answers