AnsweredAssumed Answered

Read potentiometer Value ?

Question asked by waytae on Dec 29, 2012
Latest reply on Dec 29, 2012 by waytae
Hi,

I want to program a potentiometer connected in PC2  as input  using STM32F4

I use this program

GPIO_InitTypeDef GPIO_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
 
/***********************************************
/* Configure ADC Channel 12 pin as analog input */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/***********************************************
/*** ADC1 regular channel 12 configuration ***/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* Enable ADC1 /***********************************************
ADC_Cmd(ADC1, ENABLE);
 
* Read potentiometer (voltage) value
*/
int POTGetValue(void)
{
ADC_SoftwareStartConv(ADC1);
while(ADC_GetSoftwareStartConvStatus(ADC1));
return ADC_GetConversionValue(ADC1);
}
 

Did someone know what is missing her because i can't read anything if i write "POTGetValue" in main

Thanks

Outcomes