This file provides firmware functions to manage the following functionalities of the Digital-to-Analog Converter (DAC) peripheral: More...
Go to the source code of this file.
Macros | |
#define | CR_CLEAR_MASK ((uint32_t)0x00000FFE) |
#define | DHR12R1_OFFSET ((uint32_t)0x00000008) |
#define | DHR12R2_OFFSET ((uint32_t)0x00000014) |
#define | DHR12RD_OFFSET ((uint32_t)0x00000020) |
#define | DOR_OFFSET ((uint32_t)0x0000002C) |
#define | DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC) |
#define | DUAL_SWTRIG_SET ((uint32_t)0x00000003) |
Functions | |
void | DAC_ClearFlag (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_FLAG) |
Clears the DAC channel's pending flags. More... | |
void | DAC_ClearITPendingBit (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_IT) |
Clears the DAC channel's interrupt pending bits. More... | |
void | DAC_Cmd (DAC_TypeDef *DACx, uint32_t DAC_Channel, FunctionalState NewState) |
Enables or disables the specified DAC channel. More... | |
void | DAC_DeInit (DAC_TypeDef *DACx) |
Deinitializes the DAC peripheral registers to their default reset values. More... | |
void | DAC_DMACmd (DAC_TypeDef *DACx, uint32_t DAC_Channel, FunctionalState NewState) |
Enables or disables the specified DAC channel DMA request. When enabled DMA1 is generated when an external trigger (EXTI Line9, TIM2, TIM4, TIM6, TIM7 or TIM9 but not a software trigger) occurs. More... | |
void | DAC_DualSoftwareTriggerCmd (DAC_TypeDef *DACx, FunctionalState NewState) |
Enables or disables simultaneously the two DAC channels software triggers. More... | |
uint16_t | DAC_GetDataOutputValue (DAC_TypeDef *DACx, uint32_t DAC_Channel) |
Returns the last data output value of the selected DAC channel. More... | |
FlagStatus | DAC_GetFlagStatus (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_FLAG) |
Checks whether the specified DAC flag is set or not. More... | |
ITStatus | DAC_GetITStatus (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_IT) |
Checks whether the specified DAC interrupt has occurred or not. More... | |
void | DAC_Init (DAC_TypeDef *DACx, uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct) |
Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct. More... | |
void | DAC_ITConfig (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState) |
Enables or disables the specified DAC interrupts. More... | |
void | DAC_SetChannel1Data (DAC_TypeDef *DACx, uint32_t DAC_Align, uint16_t Data) |
Set the specified data holding register value for DAC channel1. More... | |
void | DAC_SetChannel2Data (DAC_TypeDef *DACx, uint32_t DAC_Align, uint16_t Data) |
Set the specified data holding register value for DAC channel2. More... | |
void | DAC_SetDualChannelData (DAC_TypeDef *DACx, uint32_t DAC_Align, uint16_t Data2, uint16_t Data1) |
Set the specified data holding register value for dual channel DAC. More... | |
void | DAC_SoftwareTriggerCmd (DAC_TypeDef *DACx, uint32_t DAC_Channel, FunctionalState NewState) |
Enables or disables the selected DAC channel software trigger. More... | |
void | DAC_StructInit (DAC_InitTypeDef *DAC_InitStruct) |
Fills each DAC_InitStruct member with its default value. More... | |
void | DAC_WaveGenerationCmd (DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState) |
Enables or disables the selected DAC channel wave generation. More... | |
This file provides firmware functions to manage the following functionalities of the Digital-to-Analog Converter (DAC) peripheral:
=============================================================================== ##### DAC Peripheral features ##### =============================================================================== [..] The device integrates two 12-bit Digital Analog Converters that can be used independently or simultaneously (dual mode): (#) DAC1 integrates two DAC channels: (++) DAC1 channel 1 with DAC1_OUT1 as output (++) DAC1 channel 2 with DAC1_OUT2 as output (++) The two channels can be used independently or simultaneously (dual mode) (#) DAC2 integrates only one channel DAC2 channel 1 with DAC2_OUT1 as output [..] 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: (#) External event: EXTI Line 9 (any GPIOx_Pin9) using DAC_Trigger_Ext_IT9. The used pin (GPIOx_Pin9) must be configured in input mode. (#) 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() (++) 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) (#) 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 DMA1 request can be generated when an external trigger (but not a software trigger) occurs if DMA1 requests are enabled using DAC_DMACmd() DMA1 requests are mapped as following: (+) DAC channel1 is mapped on DMA1 channel3 which must be already configured (+) DAC channel2 is mapped on DMA1 channel4 which must be already configured ##### How to use this driver ##### =============================================================================== [..] (+) Enable DAC APB1 clock to get write access to DAC registers using RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE) (+) Configure DACx_OUTy (DAC1_OUT1: PA4, DAC1_OUT2: PA5, DAC2_OUT1: PA6) in analog mode. (+) Configure the DAC channel using DAC_Init() (+) Enable the DAC channel using DAC_Cmd()
Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:
http://www.st.com/software_license_agreement_liberty_v2
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file stm32f30x_dac.c.