2017-08-11 08:36 AM
I'm attempting to compile a STM32F303RE project using the Cube MX generated HAL drivers for Atollic TrueStudio 7.1. I'm getting 39 errors on stm32f3xx_hal_dma.h, stm32f3xx_hal_uart.h, and
stm32f3xx_hal_uart_ex.h wherever a HAL_StatusTypeDef or HAL_LockTypeDef type is referenced.
>:(
Each header file that has these errors has a #include 'stm32f3xx_hal_def.h' where the type is defined at the top of the file.This seems to be related to using the HAL drivers in source files other than main.c. I've created a bare bones blinky project using CubeMX and I initially had the same errors, until Iincludedstm32f3xx_hal.h in the external source file that I created that calls the HAL driver functions. Unfortunately this solution didn't work with my more complicated project.
If the header file defining the type is right there, why in the world would the compiler not see it? I feel like I'm missing something really basic, but I can't figure this out. Any help would be greatly appreciated!
Note: this post was migrated and contained many threaded conversations, some content may be missing.2017-08-11 08:42 AM
Check module import settings in project's
stm32f3xx_hal_conf.h file
2017-08-11 10:10 AM
Ok, so I'm using a UART, GPIO, and a timer in this project. Currently the stm32f3xx_hal_conf.h file shows the following:
#define HAL_MODULE_ENABLED
/*#define HAL_ADC_MODULE_ENABLED *//*#define HAL_CAN_MODULE_ENABLED *//*#define HAL_CEC_MODULE_ENABLED *//*#define HAL_NAND_MODULE_ENABLED *//*#define HAL_NOR_MODULE_ENABLED *//*#define HAL_PCCARD_MODULE_ENABLED *//*#define HAL_SRAM_MODULE_ENABLED *//*#define HAL_HRTIM_MODULE_ENABLED *//*#define HAL_OPAMP_MODULE_ENABLED *//*#define HAL_SDADC_MODULE_ENABLED *//*#define HAL_TSC_MODULE_ENABLED *//*#define HAL_COMP_MODULE_ENABLED *//*#define HAL_CRC_MODULE_ENABLED *//*#define HAL_CRYP_MODULE_ENABLED *//*#define HAL_DAC_MODULE_ENABLED *//*#define HAL_I2S_MODULE_ENABLED */#define HAL_IWDG_MODULE_ENABLED/*#define HAL_LCD_MODULE_ENABLED *//*#define HAL_LPTIM_MODULE_ENABLED *//*#define HAL_RNG_MODULE_ENABLED *//*#define HAL_RTC_MODULE_ENABLED *//*#define HAL_SPI_MODULE_ENABLED */#define HAL_TIM_MODULE_ENABLED#define HAL_UART_MODULE_ENABLED//#define HAL_USART_MODULE_ENABLED/*#define HAL_IRDA_MODULE_ENABLED *//*#define HAL_SMARTCARD_MODULE_ENABLED *//*#define HAL_SMBUS_MODULE_ENABLED *//*#define HAL_WWDG_MODULE_ENABLED *//*#define HAL_PCD_MODULE_ENABLED */#define HAL_GPIO_MODULE_ENABLED#define HAL_DMA_MODULE_ENABLED#define HAL_RCC_MODULE_ENABLED#define HAL_FLASH_MODULE_ENABLED#define HAL_PWR_MODULE_ENABLED#define HAL_CORTEX_MODULE_ENABLED//#define HAL_I2C_MODULE_ENABLEDAnd in the System Configuration section:
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */ #define USE_RTOS 0#define PREFETCH_ENABLE 1#define INSTRUCTION_CACHE_ENABLE 0#define DATA_CACHE_ENABLE 0I'm not using any extended UART or USART functionality. Just a vanilla 115200 8N1 UART.
I don't see anything that is off here, but it's very possible that I'm missing something.
Thanks for the quick response!
2017-08-14 09:34 AM
To use a HAL driver is there anything that needs to be done other than to include the header for that file? If there are other headers to include, does the order of inclusion matter?
2017-08-14 10:07 AM
The compiler needs a command line define USE_HAL_DRIVER so that the ♯ include 'stm32f3xx.h' pulls in the conf.h file.
You should review the sample/example/template projects under the Cube install, and look at the project metadata, and project specific files.
2017-08-14 11:15 AM
I just checked the Properties for the project and USE_HAL_DRIVER is in there in C/C++ Build | Settings | C Compiler | Symbols | Defined Symbols. Any other ideas?
Thanks
2017-08-14 11:39 AM
I don't use Atollic. Browse the dependency trees, grep the source, and try and understand where the definition are that you want, and why they wouldn't be pulled in.
2017-08-31 02:21 AM
This is a bug in stm32f3xx_hal_def.h. It defines HAL_StatusTypeDef and HAL_LockTypeDef, yet only after(!) including stm32f3xx.h, which in turn includes files that require HAL_StatusTypeDef and HAL_LockTypeDef. Thus if you move the include behind those definitions it compiles fine.
2017-09-11 08:34 AM
Hi
moritz.struebe
,Please share your .ioc file allowing to reproduce issue.
-Amel
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.
2017-09-11 09:09 AM
Could someone from ST confirm that is is/is not a bug?