cancel
Showing results for 
Search instead for 
Did you mean: 

Error in GPIO functions

acai
Associate II

 It seems the IDE is not able to use the ADC and any functions related to it - my error is that the ADC libraries are not importing properly We are using the HAL libraries.. Additionally, the GPIO and any functions related to it are not being supported. I'm not sure why the files aren't being found by the program. I am using version 1.12.

// define the timer and GPIO pins used
TIM_HandleTypeDef htim; (error here is unknown type name 'TIM_HandleTypeDef'; did you mean 'TIM_TypeDef'?
GPIO_InitTypeDef GPIO_InitStruct; (error here is same as line before)
ADC_HandleTypeDef hadc; (error here is unknown type name 'ADC_HandleTypeDef')
#define PWM_PIN GPIO_PIN_0 (error here is same as line before)
#define PWM_PORT GPIOA (error here is 'GPIO_Pin_0' undeclared (first use in this function)
#define ADC_PIN GPIO_PIN_1 (error here is 'GPIO_Pin_1' undeclared (first use in this function)
#define ADC_PORT GPIOA

7 REPLIES 7
Sarra.S
ST Employee

Hello @acai, thank you for posting, 

It seems that you're missing necessary header files that are not being included in your code 

Make sure you have included the following header files : 

#include "stm32xx_hal.h"

#include "stm32xx_hal_gpio.h"

#include "stm32xx_hal_adc.h"

#include "stm32xx_hal_tim.h"

Hope that helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Did I do this correctly? If so, how do I resolve the errors? 

Sarra.S
ST Employee

Hello again @acai

Actually you need to replace the xx in "stm32xx..." by your board, i can see that you are using an stm32f7, in this case : 

#include "stm32f7xx_hal.h"

#include "stm32f7xx_hal_gpio.h"

#include "stm32f7xx_hal_adc.h"

#include "stm32f7xx_hal_tim.h"

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Piranha
Chief II

Before trying to develop a software, you should learn using a file search on your computer, so that you are capable of finding the files by name or determine that such files do not exist. And then there is another secret knowledge - you can read/copy the first error and search it on the Google or other web search engine. But don't tell it anyone, this is a super secret knowledge!

These should pull properly if stm32f7xx_hal_conf.h is properly selecting the sub-components with the appropriate #defines

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

acai_0-1689185320854.png

Hi, you've been very helpful so far but I'm still getting errors. I believe I have the necessary #include statements, the files do exist, and the file path pointing to them is correct, but I'm still receiving the error. Is there anything else I should try?

Pavel A.
Evangelist III

As @Tesla DeLorean wrote, there should be file named stm32f7xx_hal_conf.h and it must properly select the sub-components. Where have you found this project source? Have you generated a new project with CubeMX/IDE or imported an example?  Otherwise, get back to the person who provided this code and request a fix.