smyslov
smyslov

Reputation: 1275

Bit definition error - IAR Workbench

I am a beginner with embedded programming and am using the IAR workbench for a project of mine using STM32F4Discovery. I am trying to compile an existing code and have a few errors at a few places regarding the bit definitions like the following:

Error[Pe020]: identifier "GPIO_PIN_SET" is undefined

Now, the GPIO_PIN_SET is defined in the file stm32f4xx_gpio_hal.h and is already included in my project. In order to resolve this issue when I looked up online, I have found this solution. However, I don't have the System tab in the General Options in my IAR Workbench. I have a full version of IAR Workbench and am not sure why the System tab is missing.

I also tried defining

#define ENABLE_BIT_DEFINITIONS

as stated in this link in my main.c file but to no avail.

Trying to set

#define STM32F4XX
#define USE_STDPERIPH_DRIVER

in the main.c file or defining the symbols STM32F4XX, USE_STDPERIPH_DRIVER in the Preprocessor tab in General Options as mentioned here also didn't help.

The solution could be very simple that I am probably overlooking but am not able to figure out what could I be missing. Any help would be appreciated

Upvotes: 0

Views: 368

Answers (1)

Including a header file in a "project" is not enough, you should actually include it (directly or indirectly) in the source file where the declarations are to be used. It would be that simple in any halfway sane development kit, but we are stuck with ST, and they force us doing it their way.

Include the "master" header in your main.c

#include "stm32f429i_discovery.h"

this would in turn include stm32f4xx_hal.h, which includes stm32f4xx_hal_conf.h, which included stm32f4xx_hal_gpio.h if the right #defines were there.

You might not have stm32f4xx_hal_conf.h

If that's the case, then copy Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_conf_template.h into your project, rename it to stm32f4xx_hal_conf.h. Otherwise just make sure that #define HAL_GPIO_MODULE_ENABLED is not commented out.

Set the right #defines

New versions of STM32CubeF4 have been released since the tutorial you've linked was written, and a few things have apparently changed. As of version 1.6.0, define STM32F429xx in Preprocessor Options, and forget the ones above. Yes, I've noticed that there is a version 1.7.0 now, let's hope that compatibility lasts this time.

Upvotes: 1

Related Questions