cancel
Showing results for 
Search instead for 
Did you mean: 

A question about DAC output voltage on STM32F429 Discovery board

mark239955
Associate II
Posted on May 04, 2014 at 08:55

Hi everyone,

I am using stm32F429 discovery boad to learn STM32 MCU. I tried to ask MCU read a voltage from ADC port(with DMA) and transfer that value to a DAC output(without DMA), just for me to familiar with these basic feature in STM The problem I got is when the ADC value is 0xFFF, it transfered the value to DAC_DHR12R2_ADDRESS and the value in DOR2 is 0xFFF as well(I am using debug mode to watch those regs), however, the LED connected on the DAC is not really light as it should be, and I measure the voltage on it, it is just 1.031V, the value in DOR2 is correct as 0xFFF, but the realastic voltage is just 1/3 of the system voltage(3V I suppose), could anyone give me a help on this issue or met this kind of problem as well? Part of my code about DAC setting:

/* DAC channel 2 (DAC_OUT2 = PA.5) configuration */ 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; 
GPIO_Init(GPIOA, &GPIO_InitStructure); 
DAC_DeInit() 
/* DAC channel2 Configuration */ 
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software; 
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; 
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; 
DAC_Init(DAC_Channel_2, &DAC_InitStructure); 
DAC_Cmd(DAC_Channel_2, ENABLE);

And in the main function, my code about DAC is:

DAC_SetChannel2Data(DAC_Align_12b_R, uhADC3ConvertedValue);//uhADC3ConvertedValue is the ADC reading value in 12-bit 
/*Enable software trigger to conversion*/ 
DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE);

Thanks for your help~ Mark
6 REPLIES 6
Posted on May 04, 2014 at 10:05

I doubt the analogue output has any real drive capability, the LED is almost certainly more load than it's going to tolerate (check the manual), suggest you measure the voltage without the LED, and add an external driver if you need too, or drive the LED with a PWM signal.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
frankmeyer9
Associate II
Posted on May 04, 2014 at 12:08

I doubt the analogue output has any real drive capability...

 

It definitely has not.

Output resistance is 1MOhm in unbuffered mode, and 15kOhm in buffered mode (unless ST has improved it's DAC peripheral for the F429, which I seriously doubt).

Just check the datasheet. You will need a driver.

Anyway, driving a LED by the DAC doesn't make much sense. LEDs have VD values of 2.4V ... 3.5V, are nonlinear, with high tolerances of current and temperature behavior. Consider PWM instead.

mark239955
Associate II
Posted on May 05, 2014 at 04:39

Thanks for help. I use multimeter to measure the current when the LED connect with a 3V battery and a resistor(forget its value), the current is 1.5mA and the brightness is reasonable and obvious. And according to the datasheet, STM32F429ZIT6 GPIO can output 20mA, and I connected it with LED without resistor in serial.

I didn't measure the current when connect to micro PIN, and didn't measure the DAC pin voltage without connectiong LED because I don't have proper wire to make those connection(still in delivering).

Anyway, I will have a try and see if that is the pin output capability problem.

Thanks again

mark239955
Associate II
Posted on May 05, 2014 at 04:41

Thanks for your help. As I said above, I will have another try when some proper wires arrived. And yes I know using a DAC output on the uC to drive LED may not make much sense, just wanna use something that I have to indicate my code working well and learn this chip step by step.

Thanks for your help

frankmeyer9
Associate II
Posted on May 05, 2014 at 09:51

...just wanna use something that I have to indicate my code working well...

 

While it is ok in theory, the DAC is in practice far too weak to drive a LED.

That is, again, one of the occasions where a scope serves one well.

mark239955
Associate II
Posted on May 05, 2014 at 12:24

Thanks mate. I do appreciate ''clive1'' and your help. I got my proper wires today, so I have enough hand to test pins I want. Yes, DAC output 2.89V(nearly 3V), and performed correctly as supposed to. I learnt that

Thanks again.