Skip to main content
SStad.1
Associate
July 29, 2020
Solved

I cannot use the HAL functions for ADC?

  • July 29, 2020
  • 24 replies
  • 8176 views

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

This topic has been closed for replies.
Best answer by Cartu38 OpenDev

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

24 replies

Tesla DeLorean
Guru
July 29, 2020

Check modules enabled in stm32l4xx_hal_conf.h

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Cartu38 OpenDev
Graduate II
July 29, 2020

Include path definitionissue ? ... could be same as : https://community.st.com/s/question/0D53W00000DJpGPSA1/file-added-and-path-added-but-still-get-no-such-file

Takes care about your include coloring ... Is such include setup effective from Eclipse point of view already ? Please could you check if such line is leading to plain or grayed include like following snapshot ... if grayed means Eclipse not able to reach

0693W000003BZiCQAW.jpg

Then if ok possibly some define to enable stuff as advised by @Community member​ 

SStad.1
SStad.1Author
Associate
July 29, 2020

0693W000003BakYQAS.jpg

Thanks for the quick answers!

I think the paths are valid, nothing is grey.

What could be the problem with define to enabel?

I'm relatively new to programming.

Cartu38 OpenDev
Graduate II
July 29, 2020

These kind of define to be uncommented in sync. with your IP(s) usage.

0693W000003BaswQAC.jpg

SStad.1
SStad.1Author
Associate
July 29, 2020

So I think #define HAL_ADC_MODULE_ENABELD is missing?0693W000003BarFQAS.jpg

Cartu38 OpenDev
Graduate II
July 29, 2020

I guess so.

SStad.1
SStad.1Author
Associate
July 29, 2020

Still the same Error.

Cartu38 OpenDev
Graduate II
July 29, 2020

Could you x2 check your Drivers/STM32L4xx_HAL_Driver/Inc & Src content ?

Are .h/.c files here ? Are .h/.c files exist ?

Takes care to small icon overlay on files like ...

0693W000003Bb5IQAS.jpg

0693W000003BbAlQAK.jpg

MM..1
Super User
July 29, 2020

I recomm create your project from scratch in CubeMX .

Cartu38 OpenDev
Graduate II
July 29, 2020

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 ...

Cartu38 OpenDev
Graduate II
July 29, 2020

@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

SStad.1
SStad.1Author
Associate
July 29, 2020

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
SStad.1Author
Associate
July 29, 2020

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.

Cartu38 OpenDev
Graduate II
July 29, 2020

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

SStad.1
SStad.1Author
Associate
July 29, 2020

Ups I thougt my first answer disapeared sorry.

SStad.1
SStad.1Author
Associate
July 29, 2020

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.:grinning_face_with_sweat:

Cartu38 OpenDev
Graduate II
July 29, 2020

"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.