This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DAC without DMA and TIMer

Hi , i'm tryiing to use a simplest sample for DAC in stm32 , so i choose the non-triggerd is the simplest way : Digital to Analog conversion can be non-triggered using DAC_Trigger_None and DAC_OUT1/DAC_OUT2 is available once writing to DHRx :

so seems i missed some thing knowinh that i declared the oclock in an other file :

< /* Includes ------------------------------------------------------------------*/

#include "stm32f2xx.h"

#include "stm32f2xx_gpio.h"
#include "stm32f2xx_dac.h"

/* Private define ------------------------------------------------------------*/
#define DAC_DHR12R2_ADDRESS 0x40007414
#define DAC_DHR8R1_ADDRESS 0x40007410

DAC_InitTypeDef DAC_InitStructure;

void DAC_Config(void)
{ GPIO_InitTypeDef GPIO_InitStruct;

/* GEPIO CONFIGURATION of DAC Pin */

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStruct);

/* GEPIO CONFIGURATION of input Pin for DHR */

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1 |GPIO_Pin_0|GPIO_Pin_2|GPIO_Pin_3| GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7 ;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStruct);

/* DAC channel1 Configuration */ DAC_InitStructure.DAC_Trigger = DAC_Trigger_None; DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; DAC_Init(DAC_Channel_2, &DAC_InitStructure);

/* Enable DAC Channel2 */ DAC_Cmd(DAC_Channel_2, ENABLE);

}

int main (void) { uint16_t DATA ;

while (1) { DATA = GPIOD ->IDR ; /* Set DAC channel2 DHR12RD register */ DAC_SetChannel2Data(DAC_Align_12b_R, DATA);

}

}

>

0