cancel
Showing results for 
Search instead for 
Did you mean: 

I cannot use the HAL functions for ADC?

SStad.1
Associate II

Hey there,

I tried to modify an existing project by using the ADC to measure a current. My problem is when I try to include the header stm32l4xx_hal_adc.h and use the functions like HAL_ADC_Start(); i will get the error undefined "reference to...". It's the same for every function declared in the header. The path for the header is added to the compiler. Some definitions from the header are recogniced only the functions aren't. Does anyone know how to solve this problem?

Thanks in advance.

0693W000003BaB4QAK.jpg

24 REPLIES 24

"start a new project" takes care due to such example packaging your primary sources may have been corrupted Thanks your first trials.

Be sure to delete your pack then expand it back from original .zip and have a new try.

SStad.1
Associate II

Thats what I did:grinning_face_with_sweat:

Here are my steps leading to result ok from scratch

1) Import SW4STM32 project

0693W000003BbT4QAK.jpg

0693W000003BbTTQA0.jpg

2) Set defines (*_conf.h file is not local to project but part of the pack ... considering file system. In other words I've not a local copy ...)

0693W000003Bc8gQAC.jpg

3) Add source code to main.c

0693W000003Bc8lQAC.jpg

4) Add required .c files

0693W000003BbSaQAK.jpg

0693W000003Bc9AQAS.jpg

5) Get compile success

0693W000003Bc0OQAS.jpg

SStad.1
Associate II

OK I fixed it now. So before I can use this fuctions to read the ADC i have to initialize the ADC first, i guess to take an initailization code from cubemx and copy/paste it into my project is not a good idea?

Cartu38 OpenDev
Lead II

cubemx is valuable but having to care take care to all dependencies ...

Please tag as answered once ok