cancel
Showing results for 
Search instead for 
Did you mean: 

My DAC outputs inverted values (0000 = 3.3V and 4095 = 0V)

jean_prieur
Associate III
Posted on July 14, 2014 at 12:19

Hello,

I have a trouble with my DAC, for example when I set the DAC output (Channel1 orChannel2) to the maximum voltage, the DAC generate the minimum voltage:

DAC_SetChannel1Data(DAC_Align_12b_R, 4095);

Vout

~

0V

DAC_SetChannel1Data(DAC_Align_12b_R, 0);

Vout

~

3.3V

DAC_SetChannel1Data(DAC_Align_12b_R, 1000);

Vout

~

0.8V The strange thing is, I have two test boards, and the problem happens only on one board. The other board have a correct behavior, with the same project! Do you have any ideas? Thanks a lot!

DAC_SetChannel1Data(DAC_Align_12b_R, 4095);

Vout

~

0V

DAC_SetChannel1Data(DAC_Align_12b_R, 4095);

Vout

~

0V #whiskey-tango-foxtrot #oscar-mike-golf
28 REPLIES 28
frankmeyer9
Associate II
Posted on July 14, 2014 at 12:44

Are you sure you are measuring correctly ?

Connecting the input of the measuring device to the 3.3V supply, and Ground to the DAC output, you would surely measure an ''inverse'' output.

Or have you added an inverting opamp as buffer amplifier ?

jean_prieur
Associate III
Posted on July 14, 2014 at 14:14

No, I measure the direct output pin of the STM32F4, and I'm sure of my method :)

And the same test on the other board, the good result...

Maybe it's a hardware failure into the STM32 DAC, for example maybe I created a short circuit during a test and now the DAC is ''destroyed''? But DAC are protected isn'nt it?

frankmeyer9
Associate II
Posted on July 14, 2014 at 15:50

Maybe it's a hardware failure into the STM32 DAC, for example maybe I created a short circuit during a test and now the DAC is ''destroyed''? But DAC are protected isn'nt it?

 

Probably only by it's high output impedance, which presumably prevents any substantial current flow.

But there is no documented way to achieve such an ''inverse'' output.

Perhaps there is something wrong with the voltage reference (shared with the ADC) ?

jean_prieur
Associate III
Posted on July 14, 2014 at 17:45

Perhaps there is something wrong with the voltage reference (shared with the ADC) ?

I don't think, I have a nice 3.3V on each votage references (including VREF+ and VDDA)...

DAC_SetChannel1Data(DAC_Align_12b_R, 4095);

Vout

~

0V

DAC_SetChannel1Data(DAC_Align_12b_R, 4095);

Vout

~

0V
Posted on July 14, 2014 at 17:58

Make sure you have fully populated any configuration parameters/structures.

But DAC are protected isn'nt it?

If evaporating silicon acting as a fuse is classed as ''protection''. The ESD diodes may try to clamp to the supply, but aren't current limiting and recoverable like a poly-fuse. Causing the pin to invert doesn't really sound plausible.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jean_prieur
Associate III
Posted on July 15, 2014 at 10:38

Hi,

I test my ADCs and they are working well. This is my ADC config:

void
DAC_Config(
void
)
{
/* Preconfiguration before using DAC----------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
/* DMA1 clock and GPIOA clock enable (to be used with DAC) */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_GPIOA, ENABLE);
/* DAC Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
DAC_InitStructure.DAC_Trigger = DAC_Trigger_None;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_StructInit(&DAC_InitStructure);
/* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
DAC_DeInit();
}

void
Set_DAC_Ch1_Voltage(
float
voltage)
{
/* 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_1, &DAC_InitStructure);
/* Enable DAC Channel1 */
DAC_Cmd(DAC_Channel_1, ENABLE);
/* Set DAC channel1 DHR12RD register */
DAC_SetChannel1Data(DAC_Align_12b_R, voltage);
}

Not sure if it's a good init but it's working well for my other board...
frankmeyer9
Associate II
Posted on July 15, 2014 at 11:10

First, you do not need to configure the DAC each time you want to set a value. This just wastes time.

This line should throw at least a compiler warning:

DAC_SetChannel1Data(DAC_Align_12b_R, voltage);

The voltage parameter is float, but

DAC_SetChannel1Data

() expects an uint No wonder you get those strange results. A simple cast, probably with scaling, should suffice here.
jean_prieur
Associate III
Posted on July 15, 2014 at 12:03

First, you do not need to configure the DAC each time you want to set a value. This just wastes time.

Done, thanks! This line should throw at least a compiler warning:

DAC_SetChannel1Data(DAC_Align_12b_R, voltage);

The voltage parameter is float, but

DAC_SetChannel1Data

() expects an uint

No wonder you get those strange results. A simple cast, probably with scaling, should suffice here.

Done, in fact it was just a try. But my problem is still here... Now I really think that it's a hardware problem, I probably created a short circuit on the output analog pin during a test under voltage. Maybe hardware designer from ST would know what happened...
frankmeyer9
Associate II
Posted on July 15, 2014 at 13:17

But my problem is still here... Now I really think that it's a hardware problem, I probably created a short circuit on the output analog pin during a test under voltage. Maybe hardware designer from ST would know what happened...

 

If your 'problematic' board and the reference board are identical in both software and hardware, and still behave differently, it might well be a hardware problem.

And it might be worth trying to ask ST, albeit I'm not sure if they are interested.

Have you tried the other DAC channel/output instead, does it behave the same way ?