Skip to main content
hmorris
Associate
Aug 21, 2019 6:20 PM UTC
Solved

Cube generated code doesn't compile, multiple structs and enums undefined/correct headers not linked.

I am attempting to create a program to implement SPI communication from my STM32H753XI MCU, all I did to do this was start a new project in Keil's uVision and generate the code from Cube after selecting my pinouts.

Once my code was generated, however, I attempted to compile it and got 30 errors regarding identifiers that haven't been defined. These appear to be structs and enums from other header files that haven't been included in my project when I generated the code, I've listed examples below.

C:\Users\User\AppData\Local\Arm\Packs\Keil\STM32H7xx_DFP\2.3.0\CMSIS\Driver\SPI_STM32H7xx.h(284): error: #20: identifier "SPI_HandleTypeDef" is undefined

"" "" error: #20: identifier "HAL_SPI_STATE_ABORT" is undefined

"" "" error: #20: identifier "HAL_SPI_STATE_RESET" is undefined

"" "" error: #20: identifier "HAL_SPI_STATE_ERROR" is undefined

These are just a few of them. Is this a mistake I made when generating the code from CubeMX?

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Aug 21, 2019 6:49 PM UTC

CubeMX is supposed to generate viable projects.

You might look at the stm32h7xx_hal_conf.h file in your project directory to see what sub-components have been pulled.

Keil looks to be using it's own libraries here, not the HAL ones, so perhaps some incompatible mixing-n-matching going on. You should be using CubeMX to generate the project, not Keil.

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

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Aug 21, 2019 6:49 PM UTC

CubeMX is supposed to generate viable projects.

You might look at the stm32h7xx_hal_conf.h file in your project directory to see what sub-components have been pulled.

Keil looks to be using it's own libraries here, not the HAL ones, so perhaps some incompatible mixing-n-matching going on. You should be using CubeMX to generate the project, not Keil.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
hmorris
hmorrisAuthor
Associate
Aug 21, 2019 7:22 PM UTC

Thank you for the super quick response!

This is my first time utilizing this software so I didn't realize it would be an issue starting the project in Keil instead of CubeMX.

I went ahead and redid everything, this time from CubeMX, and it built correctly without any errors, I think that was it!

Thank you!