when i added my ADC source to my project for stm32F407VG in keilv5. ADC.c ADC.h
i used this tutorial stm32f4-discovery.net/.../
here in adc.c it was defined functions
void ADC_CommonInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct) { uint32_t tmpreg1 = 0; /* Check the parameters */ assert_param(IS_ADC_MODE(ADC_CommonInitStruct->ADC_Mode)); assert_param(IS_ADC_PRESCALER(ADC_CommonInitStruct->ADC_Prescaler)); assert_param(IS_ADC_DMA_ACCESS_MODE(ADC_CommonInitStruct->ADC_DMAAccessMode)); assert_param(IS_ADC_SAMPLING_DELAY(ADC_CommonInitStruct->ADC_TwoSamplingDelay)); /*---------------------------- ADC CCR Configuration -----------------*/ /* Get the ADC CCR value */ tmpreg1 = ADC->CCR;
/* Clear MULTI, DELAY, DMA and ADCPRE bits */ tmpreg1 &= CR_CLEAR_MASK;
/* Configure ADCx: Multi mode, Delay between two sampling time, ADC prescaler, and DMA access mode for multimode */ /* Set MULTI bits according to ADC_Mode value */ /* Set ADCPRE bits according to ADC_Prescaler value */ /* Set DMA bits according to ADC_DMAAccessMode value */ /* Set DELAY bits according to ADC_TwoSamplingDelay value */ tmpreg1 |= (uint32_t)(ADC_CommonInitStruct->ADC_Mode | ADC_CommonInitStruct->ADC_Prescaler | ADC_CommonInitStruct->ADC_DMAAccessMode | ADC_CommonInitStruct->ADC_TwoSamplingDelay);
/* Write to ADC CCR */ ADC->CCR = tmpreg1; }
in header file adc.h it defined void ADC_CommonInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct);
it is done too for ADC_Init,ADC_RegularChannelConfig now when i compile it in keil v5 it returns errors
.\OBJ\STM324xG.axf: Error: L6218E: Undefined symbol ADC_CommonInit (referred from tm_stm32f4_adc.o). .\OBJ\STM324xG.axf: Error: L6218E: Undefined symbol ADC_Init (referred from tm_stm32f4_adc.o). .\OBJ\STM324xG.axf: Error: L6218E: Undefined symbol ADC_RegularChannelConfig (referred from tm_stm32f4_adc.o).
how can i solve my problem???
"when i compile it in keil v5 it returns errors"
Not actually true. It isn't compilation errors you see - it's linking errors.
"how can i solve my problem???"
Maybe add adc.c to your project? Making use of the adc.h file isn't enough for the linker to be happy - it also needs the implementation.
thanks finally i concluded my problem is very common in between c++ developer. stackoverflow.com/.../what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix
it's special case is recursive errors.... we use like this structure in header file for preventing recursive problems
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ADCCONFIG_H__ #define __ADCCONFIG_H__
#ifdef __ADCCONFIG_GLOBALS__ #define __ADCCONFIG_EXT__ #else #define __ADCCONFIG_EXT__ extern #endif
best regards stakprogramer