2013-09-17 03:22 PM
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;GPI
O_
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@4095PA5: 0.002V@0, 2.909V@4095The range of PA4 becomes smaller? Don't really know why is that... Thanks a lot! #discovery #dac #stm32l2013-09-18 09:14 PM
Check if solder bridge SB2 and jumper JP1 are set for measuring Idd. This puts a load on PA4.
Regards, Hal2013-09-19 11:09 AM
Thanks Hal! It works after I turn the JP1 off and remove the SB2!