cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 DAC won't drive to zero

joesnyder
Associate II
Posted on December 07, 2015 at 18:33

I have the DAC output of my STM32F44 feeding into a non-inverting op amp. Everything is working, but not real great. The problem is at the lower end, and gets worse the closer you get to zero.

For instance, my AVREF is 3.00V. If I write 4095 to the DAC, I get 3.00V out. If I write zero to the DAC, I'm seeing about 80mV. The problem seems to be linear - writing 2048 gives about 1.69V (about .04 above the expected 50% level). I disconnected the op amp portion because I thought it might be interfering. With the DAC pin floating, I see the same issue. I tied it to ground through a 10K, and same issue. I can account for the non-linearity in code, but not being able to drive to zero is a problem. I can't find anything in the data sheet or reference manual about it being non-linear. The CubeMX DAC code is:

/* DAC init function */
void MX_DAC_Init(void)
{
DAC_ChannelConfTypeDef sConfig;
/**DAC Initialization
*/
hdac.Instance = DAC;
HAL_DAC_Init(&hdac);
/**DAC channel OUT1 config
*/
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1);
/**DAC channel OUT2 config
*/
HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_2);
}

Then I'm calling it using: MX_DAC_Init(); HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 0x0); HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
6 REPLIES 6
Posted on December 07, 2015 at 20:12

> The problem seems to be linear

>[...]

> I can't find anything in the data sheet or reference manual about it being non-linear. 

But it is not non-linear, according to your finding, is it.

> I can account for the non-linearity in code, but not being able to drive to zero is a problem. 

Did you read the datasheet? What does it say for maximum output excursion with buffer ON? Try to switch the buffer OFF.

JW

joesnyder
Associate II
Posted on December 07, 2015 at 20:49

I don't know why I put 3.00V...my reference voltage is 3.30V, and when the DAC is 4095, I get 3.30V out.

I disabled the buffer, and that appears to have helped a little.  Writing the DAC to 0x00 now gives me 45-50mV.  The datasheet says with the buffer off, lower DAC-out voltage is .5mV typical. 

Posted on December 07, 2015 at 22:15

And what voltage do you measure on your ground pins?

JW

Uwe Bonnes
Principal III
Posted on May 23, 2017 at 14:40

> I can't find anything in the data sheet

Read the datasheet again. Remember that all electronic has problems when output voltage comes to the rails. Either you use the DAC unbuffered, then Vout can get near zero, or you use it buffered, then vout min is several tens of mV. But unbuffered means that the load must be high impedance. Look for values in the datasheet.

AvaTar
Lead
Posted on May 23, 2017 at 15:03

Didn't check for your particular MCU, but ST's DAC implementation used to be like this:

With unbuffered output, you have a voltage swing nearly between the rails, and an output impedance of 1 Mega-Ohm.

With buffered output, you have 15k output impedance, but reduced swing of up to 200mV at both rails (+200mV .. VRef-200mV).

Check the datasheet carefully. What is the input impedance of your opamp driver ?

Posted on May 23, 2017 at 15:11

Re-checked it, and is still about the same, look at page 149 of the datasheet.