cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f100 DAC wrong Behavior

gerardo
Associate II
Posted on October 27, 2014 at 19:20

Hi guys,

I´m having some difficulties getting the DAC working properly with the STM32F100 LQFP48pins.

First of all, Reference Manual says the following

On 64-pin packages and packages with less pins

The VREF+ and VREF- pins are not available, they are internally connected to the ADC

voltage supply (VDDA) and ground (VSSA).

I´ve in my PCB VDDA connected to 3,3v.

11.3.5 DAC output voltage

Digital inputs are converted to output voltages on a linear conversion between 0 and VREF+.

The analog output voltages on each DAC channel pin are determined by the following

equation:

DACoutput=VREF*DOR/4095

Mi code is the following;

    GPIO_InitStruct.GPIO_Pin   = GPIO_Pin_4;

    //GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStruct.GPIO_Mode  = GPIO_Mode_AIN;

    GPIO_Init(GPIOA_BASE, &GPIO_InitStruct);

    // DAC channel1 Configuration

    DAC_StructInit(&DAC_InitStruct);

    DAC_InitStruct.DAC_Trigger = DAC_Trigger_None;

    DAC_InitStruct.DAC_WaveGeneration = DAC_WaveGeneration_None;

    DAC_InitStruct.DAC_OutputBuffer = DAC_OutputBuffer_Disable;

    

DAC_Init(xDACTable[DAC1].eDAC_Channel, &DAC_InitStruct);

DAC_Cmd(DAC_Channel_1, ENABLE);

DAC_SetChannel1Data(DAC_Align_12b_R, 0x0FFF);

DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);

Loading in DAC DOR register the Value =4095 I only get 2,5v instead of 3,3v 

Anyone knows why am I doing wrong?
5 REPLIES 5
Posted on October 27, 2014 at 19:27

Anyone knows why am I doing wrong?

Loading the pin too heavily?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gerardo
Associate II
Posted on October 28, 2014 at 15:37

0690X00000602vFQAQ.jpg

If I Remove R112 and I get the measurement of DAC output I get the desired 3,3v.

If I relocate R112 and removing R113 then i get 3,3v. Then If I relocate R113 again I get 2,5v. 

Is correct the definition of  GPIO_InitStruct.GPIO_Mode  = GPIO_Mode_AIN; for a DAC Output??

Posted on October 28, 2014 at 15:58

Is correct the definition of  GPIO_InitStruct.GPIO_Mode  = GPIO_Mode_AIN; for a DAC Output??

Yes, it disables all the digital logic on the pin including the schmitt trigger input.

Might consider

DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gerardo
Associate II
Posted on October 28, 2014 at 16:10

What does it mean?

11.3.2 DAC output buffer enable

The DAC integrates two output buffers that can be used to reduce the output impedance,

and to drive external loads directly without having to add an external operational amplifier.

frankmeyer9
Associate II
Posted on October 28, 2014 at 16:13

Might consider

 

DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;

 

Correct.

I'm repeating myself here, but sometimes when writing software, one needs to take the corresponding hardware into consideration.

Take a look at the datasheet. The load resistance presented to the DAC output in your circuit is almost two orders of magnitude too small for unbuffered mode (1MOhm vs. 32kOhm, ignoring opamp input and C leakage).