2016-02-11 11:43 AM
Hello ;
I have problem to get analog output on PA4 ( DAC1 , ch1) ; Here down my code to set the DAC1 could you tell me what is missing here ? I m getting some few mv even when I set the a full scale 4096 :
DAC_SetChannel1Data(DAC1, DAC_Align_12b_R, 4096);
Thank you inadvanced
/* DAC Periph clock enable ----------------------------------------*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
/* SYSCFG Periph clock enable -------------------------------------*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Enable GPIOA Periph clock --------------------------------------*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure PA.04 (DAC1_OUT1),as analog */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* DAC deinitialize */
DAC_DeInit(DAC1);
/* Fill DAC InitStructure */
DAC_InitStructure.DAC_Trigger =DAC_Trigger_None;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bits2_0;
DAC_InitStructure.DAC_Buffer_Switch = DAC_BufferSwitch_Enable;
/* DAC channel1 Configuration */
DAC_Init(DAC1, DAC_Channel_1, &DAC_InitStructure);
/* Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
automatically connected to the DAC converter. */
DAC_Cmd(DAC1, DAC_Channel_1, ENABLE);
/* Set DAC Channel1 DHR register: DAC1_OUT */
DAC_SetChannel1Data(DAC1, DAC_Align_12b_R, 0);
2016-02-12 09:17 AM
2016-02-12 10:45 AM
Still I could not solve it ; Can it be a library bug ?
I'd suspect the board/hardware first. Check schematic, solder bridges, and VREF2016-02-14 11:28 AM