cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4-Discovery ADC problem using HAL driver

zivadin
Associate II
Posted on January 17, 2015 at 18:54

Hi,

I'm using HAL driver to configure ADC module.  This is my code:

void adc_config()

{

  AdcHandle.Instance = ADC1;

  __ADC1_CLK_ENABLE();

  HAL_ADC_DeInit(&AdcHandle);

  AdcHandle.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;

  AdcHandle.Init.Resolution = ADC_RESOLUTION12b;

  AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;

  AdcHandle.Init.ScanConvMode = DISABLE;

  AdcHandle.Init.EOCSelection = DISABLE;

  AdcHandle.Init.ContinuousConvMode = ENABLE;

  AdcHandle.Init.DMAContinuousRequests = DISABLE;

  AdcHandle.Init.NbrOfConversion = 1;

  AdcHandle.Init.DiscontinuousConvMode = DISABLE;

  AdcHandle.Init.NbrOfDiscConversion = 0;

  AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

  AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1;

  HAL_ADC_Init(&AdcHandle);

  ADC_ChannelConfTypeDef sConfig;

  sConfig.Channel = ADC_CHANNEL_10; //PC0

  sConfig.Rank = 1;

  sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;

  sConfig.Offset = 0;

  HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);

}

int adc_convert()

{

HAL_ADC_Start(&AdcHandle);//Start the conversion

HAL_ADC_PollForConversion(&AdcHandle,10);//Processing the conversion

return HAL_ADC_GetValue(&AdcHandle); //Return the converted data

}

When I compile that, i get an error messages ''undefined reference to `HAL_ADC_DeInit'''. The error message is the same for all HAL_ADC functions... I use Eclipse + GCC.

When I manually open stm32f4xx_hal_adc.c file, I can find the definition of the HAL functions.

When I use CTR+Left click on the function in main.c, i get the .h file od hal_adc, but when i again click on the function i don't get the .c file of the hal_adc. 

What is the problem?

Thanks

#adc #eclipse #hal
1 REPLY 1
Amel NASRI
ST Employee
Posted on January 19, 2015 at 17:25

Hi,

File stm32f4xx_hal_adc.c has to be added into your porject tree, not only the header file so that functions can be used.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.