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

Except this guys is starting from a STM32Cube expansion pack according snapshot sharing.

Good question is @Community member​  how to you import such project from pack ? Some tricks may exist here depending of your way of working ...

SStad.1
Associate II

Yes the project I'm starting with is an example from the IBM Watson expansion pack. It collects sensor data and sends the data to the IBM Cloud with MQTT protocol. There were different project files for Kei, EWARM and SW4STM32, the cube ide transformed the SW4STM32 project to the workspace when I first started it.

SStad.1
Associate II

Actually this is a project from the IBM Watson expansion pack. It collects sensor data and then sends the data to the IBM Cloud via MQTT protocoll.

The project file was a SW4STM32 project. The cube ide transformed into the workspace after i started it.

SStad.1
Associate II

Ups I thougt my first answer disapeared sorry.

@Community member​ ok I've got a try myself to your STM32Cube expansion pack.

Doing proper import and adding  HAL_ADC_Start(&hadc); to main.c I'm facing same issue as you.

Issue is not .h lack but .c one 🙂

Just add .c file and your project build is going to be successful !

0693W000003BbSaQAK.jpg

@MM..1​  Such STM32Cube exansion pack is not STM32CubeMX compliant and as addon promoting SW4STM32 material not STM32CubeIDE one ...

FYI proper import working model is:

0693W000003BbT4QAK.jpg

0693W000003BbTTQA0.jpg

Solution is not .h but .c lack assuming you've rightly setup proper defines are shared previously. Setting reauired defines are taking care of .h include but still .c files are required from you.0693W000003BbSaQAK.jpg

Thank you very much.

You are the best=)

You're welcome. Please tag such topic as Answered will help community.

SStad.1
Associate II

I tried to start a new project, to make erverything right from the beginning. I uncommented the module in config.h and added stm32l4xx_hal_adc.c and stm32l4xx_hal_adc_ex.c as well. I included the header files in main.c and tried to initailize the ADC, now i have the same errors again.😅