DAC on stm32f4

169 views
Skip to first unread message

kittipon meesompop

unread,
Jan 13, 2014, 11:26:38 AM1/13/14
to python-o...@googlegroups.com
Hello,
i am trying to write a native-c with DAC functional. But it does not work.
Can someone give me some advices please.

Following are my configuration for the DAC:

PmReturn_t _init_dac(uint32_t DAC_Channel){

PmReturn_t retval = PM_RET_OK;


if(NATIVE_GET_NUM_ARGS() != 1)

{

PM_RAISE(retval, PM_RET_EX_TYPE);

return retval;

}

DAC_InitTypeDef DAC_InitStruct;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //also tried with GPIO_Mode_AIN like the suggestion in the datasheet too

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);


RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

DAC_InitStruct.DAC_Trigger = DAC_Trigger_None;

DAC_InitStruct.DAC_WaveGeneration = DAC_WaveGeneration_None;

DAC_InitStruct.DAC_OutputBuffer = DAC_OutputBuffer_Enable;

DAC_Init(DAC_Channel_1, &DAC_InitStruct);

DAC_Cmd(DAC_Channel_1, ENABLE);


DAC_SetChannel1Data(DAC_Align_12b_R, 1000);

return retval;

}


I expect, that i can measure the a voltage with 1000 counts value at pin PA4. But i can not measure anything ( ~ 0V)

Thank you for the help in advance

best regards


John Evers

unread,
Feb 20, 2014, 9:48:25 PM2/20/14
to python-o...@googlegroups.com

I have not verified this will work but try:

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;

Reply all
Reply to author
Forward
0 new messages