AnsweredAssumed Answered

STM32L- how to set DAC reference voltage

Question asked by shan on Sep 18, 2013
Latest reply on Sep 19, 2013 by shan
Hi all,
I'm working on STM32L-discovery board and currently I'm trying to configure two analog outputs with DAC.  I am able to see the result from the output pin but there seems to be some bias from the zero reference voltage.  (Say, when I set the digital value to zero, the analog output is 90 mV)  How should I modify my code to get the value zero?  The following is my configuration:

void AO_Config()
{
     GPIO_InitTypeDef     GPIO_InitStructure;
     DAC_InitTypeDef     DAC_InitStructure;

     RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
     RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | 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_InitStructure.DAC_Trigger = DAC_Trigger_None;
     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);

     DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
     DAC_Init(DAC_Channel_1, &DAC_InitStructure);
     DAC_Cmd(DAC_Channel_1,ENABLE);

     DAC_SetChannel1Data(DAC_Align_12b_R, 0x0000);
     DAC_SetChannel2Data(DAC_Align_12b_R, 0x0000);
}


[edit]
When I used the scope to monitor the pin, the result is as the following:
PA4:   0.558V@0, 2.312V@4095
PA5:   0.002V@0, 2.909V@4095

The range of PA4 becomes smaller?  Don't really know why is that... 

Thanks a lot!


Outcomes