cancel
Showing results for 
Search instead for 
Did you mean: 

DAC output not working

danieloneill9
Associate II
Posted on September 05, 2012 at 04:38

Hi All,

I had the DAC working using DMA to out put a sinewave continuously and it seems to have stopped working when I tried to change which timer I triggered off. After changing the timer configuration back it still doesn't work.

I believe I configure everything I need to and I have code that read DAC->DOR1 out via the USART and it shows this data updating as I expect but I don't see any voltage on the DAC pin.

Any ideas?

Regards,

Daniel

#dac
12 REPLIES 12
Posted on September 05, 2012 at 05:13

Sounds like a pin configuration or VDDA issue.

What part are we talking about?

What does the pin config code look like?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
danieloneill9
Associate II
Posted on September 06, 2012 at 08:05

Hi Clive,

The part is a STM32F103.

The pin config code is as follows:

  GPIO_InitTypeDef GPIO_InitStructure = {

      GPIO_Pin_4,

      GPIO_Speed_50MHz,

      GPIO_Mode_AIN

  };

  GPIO_Init(GPIOA, &GPIO_InitStructure);

Cheers,

Daniel

szbrozek9
Associate II
Posted on September 06, 2012 at 08:53

I noticed that you didn't use the GPIO configuration system in the canonical way, but checking the GPIO_InitStruct suggests that what you did should work. Quick overall DAC checklist:

Did you turn on the DAC and GPIO clocks before configuring the peripherals:

RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

Did you configure the DAC:

 

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_1, &DAC_InitStructure);

DAC_Cmd(DAC_Channel_1, ENABLE);

Did you actually write something to the DAC:

DAC_SetChannel1Data(DAC_Align_12b_R, 0x07FF);

DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);

danieloneill9
Associate II
Posted on September 06, 2012 at 09:31

clocks

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

DAC

  DAC_InitTypeDef DAC_InitStructure = {

    DAC_Trigger_T4_TRGO,              /*DAC_Trigger*/

    DAC_WaveGeneration_None,          /*DAC_WaveGeneration*/

    DAC_LFSRUnmask_Bit0,              /*DAC_LFSRUnmask_TriangleAmplitude*/

    DAC_OutputBuffer_Disable         /*DAC_OutputBuffer*/

  };

I have a DMA loop that writes to the DAC. When I poll the DAC->DOR1 register I see data in there changing as I expect.

szbrozek9
Associate II
Posted on September 06, 2012 at 09:44

szbrozek9
Associate II
Posted on September 06, 2012 at 09:45

szbrozek9
Associate II
Posted on September 06, 2012 at 09:46

danieloneill9
Associate II
Posted on September 06, 2012 at 12:21

Hi All,

A poke round and a clean build later and the DAC is working.....

Thanks for the help.

Cheers,

Daniel

megapin
Associate
Posted on January 29, 2013 at 19:53

Hi!

board: STM32VL Discovery

DAC1,DAC2 DORx Register = 0;

Why out voltage = 60 mV?