2016-08-29 06:56 PM
Hi,
I am using pin PA4 as a DAC output on an STM32F405. I then have a unity gain op-amp buffer. My supply is 3.3V. What I want to do is rather than create a SINE output at some frequency, is to generate a DC signal. For example, at 2048 (ADC/2) I want a DC level of 1.65. Basically, a DC level that is 3.3/4096. Can someone please provide a sample DAC setup that would guide me on this, or some hints? Thanks!2016-08-30 12:02 AM
simple.
Fist, go to dac examples, delete dma/timer stuff, and use software register update function, that it !GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
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_1, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_1, ENABLE);
DAC_SetChannel1Data(DAC_Align_12b_L, TYPE_DATA);
this may or may not work, but you can test it anyway
2016-08-30 06:31 AM
Hi roofie01,
I recommend the ''SimpleConversion'' example in at this path: STM32Cube_FW_F4_V1.13.0\Projects\STM324xG_EVAL\Examples\DAC\DAC_SimpleConversionYou can enable the output buffer in the code there to reduce the output impedance, and to drive external loads directly without having to add an external operational amplifier-Hannibal-2016-08-31 05:04 PM
Thanks! Will try it.
2016-08-31 05:06 PM
Great, I did not know it could drive directly. As I designed the circuit, it was originally set up for an LPF active circuit, so I needed the op amp anyhow. Now requirements have changed and only a occasionally changing DC level is required. (about 1 to 2 Hz )
Thank you!