AnsweredAssumed Answered

STM32F4-Discovery ADC problem using HAL driver

Question asked by despotovic.zivadin on Jan 17, 2015
Latest reply on Jan 19, 2015 by Amel N
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

Outcomes