STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_dac.c File Reference

This file provides firmware functions to manage the following functionalities of the Digital-to-Analog Converter (DAC) peripheral: More...

#include "stm32f0xx_dac.h"

Macros

#define CR_CLEAR_MASK   ((uint32_t)0x0000003E)
 
#define DHR12R1_OFFSET   ((uint32_t)0x00000008)
 
#define DOR_OFFSET   ((uint32_t)0x0000002C)
 

Functions

void DAC_DeInit (void)
 Deinitializes the DAC peripheral registers to their default reset values. More...
 
void DAC_Init (uint32_t DAC_Channel, DAC_InitTypeDef *DAC_InitStruct)
 Initializes the DAC peripheral according to the specified parameters in the DAC_InitStruct. More...
 
void DAC_StructInit (DAC_InitTypeDef *DAC_InitStruct)
 Fills each DAC_InitStruct member with its default value. More...
 
void DAC_Cmd (uint32_t DAC_Channel, FunctionalState NewState)
 Enables or disables the specified DAC channel. More...
 
void DAC_SoftwareTriggerCmd (uint32_t DAC_Channel, FunctionalState NewState)
 Enables or disables the selected DAC channel software trigger. More...
 
void DAC_SetChannel1Data (uint32_t DAC_Align, uint16_t Data)
 Set the specified data holding register value for DAC channel1. More...
 
uint16_t DAC_GetDataOutputValue (uint32_t DAC_Channel)
 Returns the last data output value of the selected DAC channel. More...
 
void DAC_DMACmd (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, TIM3, TIM6 or TIM15 but not a software trigger) occurs. More...
 
void DAC_ITConfig (uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState)
 Enables or disables the specified DAC interrupts. More...
 
FlagStatus DAC_GetFlagStatus (uint32_t DAC_Channel, uint32_t DAC_FLAG)
 Checks whether the specified DAC flag is set or not. More...
 
void DAC_ClearFlag (uint32_t DAC_Channel, uint32_t DAC_FLAG)
 Clears the DAC channel's pending flags. More...
 
ITStatus DAC_GetITStatus (uint32_t DAC_Channel, uint32_t DAC_IT)
 Checks whether the specified DAC interrupt has occurred or not. More...
 
void DAC_ClearITPendingBit (uint32_t DAC_Channel, uint32_t DAC_IT)
 Clears the DAC channel's interrupt pending bits. More...
 

Detailed Description

This file provides firmware functions to manage the following functionalities of the Digital-to-Analog Converter (DAC) peripheral:

Author
MCD Application Team
Version
V1.0.1
Date
20-April-2012
  • DAC channel configuration: trigger, output buffer, data format
  • DMA management
  • Interrupts and flags management
 *
===============================================================================
                       ##### DAC Peripheral features #####
===============================================================================
   [..] The device integrates one 12-bit Digital Analog Converters refered as
        DAC channel1 with DAC_OUT1 (PA4) as output
 
   [..] Digital to Analog conversion can be non-triggered using DAC_Trigger_None
        and DAC_OUT1 is available once writing to DHRx register using 
        DAC_SetChannel1Data().
 
   [..] 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, TIM3, TIM6 and TIM15 
            (DAC_Trigger_T2_TRGO, DAC_Trigger_T3_TRGO...)
            The timer TRGO event should be selected using TIM_SelectOutputTrigger()
 
        (#) Software using DAC_Trigger_Software
 
   [..] The DAC channel 1 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.
 
   [..] 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
        VEF+ 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
   
                     ##### How to use this driver #####
===============================================================================
   [..]
        (+) Enable DAC APB1 clock to get write access to DAC registers
            using RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE)
             
        (+) Configure DAC_OUT1 (DAC_OUT1: PA4) in analog mode
            using GPIO_Init() function  
             
        (+) Configure the DAC channel using DAC_Init()
             
        (+) Enable the DAC channel using DAC_Cmd()
Attention

© COPYRIGHT 2012 STMicroelectronics

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.