cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 minimalistic project template WITHOUT STM32CubeIDE C Code generation. How to include ST HAL and/or LL drivers into an empty project?

AAnth.1
Senior

Hi there

I moved from TI DSPs using Code Composer Studio to a STM32F4 MCU using STM32CubeIDE and I already struggle with the first steps. While I fancy the automatic Code generation that the STM32CubeIDE configurator offers, I would like to start my first projects without it in order to get a better understanding of the MCU and the CubeIDE.

I am coming straight to the point:

  1. How do I best create an empty project such that I afterwards include the pre-defined functions (peripherals such as ADC, Timers etc.)?
    1. My current approach has been: File->New->STM32 Project->Target Project Type: Empty (shown in figure CubeIDE)
    2. This seems to do the job (shown in CubeIDE1). But that brings me directly to question nr 2:
  2. Once I have this empty project, I would like to include the necessary pre-defined functions, header files etc. Where and how in the CubeIDE (project settings) do I do the proper linking and including (see CubeIDE2)?
  3. I have downloaded the STM32CubeF4 driver package and read the getting started manual. So now the question is how to include the necessary driver files into my project via STMCubeIDE.
  4. Is there any document that describes this procedure and the required header files/driver files etc?

I hope I am not asking for too much help here.

Thank you,

13 REPLIES 13
AAnth.1
Senior

Hi all,

short update. I believe I finally managed to find my way through the IDE and the project options to include all necessary header files, setup the defines etc. It was a good exercise for me in order to get a better understanding as of which files are actually necessary and from where these header files are used/called.

I actually got my point proven to go through this (painful) exercise of creating the project manually step-by-step because using the code generation from CubeIDE, the highly critical header files stm32f4xx.h and stm32f4xx_hal.h were called within a header file usb_host.h which is a header file which I do not manage to find in the stm32cubef4 driver package (please correct me when I am wrong). I would have blindly believed the IDE that usb_host.h is crucial for my project and I would have copied this mistake from one project to another.

I now seem to have a proper minimalistic base project where only the absolute necessary header files are present and NO source files (neither HAL or LL). Next step is to include the necessary source files that are used to initialize the MCU clock, and I will then take it from there to probably make my first LED blink.

It was a tough run, and I would have not managed to get this far without your help, which I highly appreciate.

Thank you,

Piranha
Chief II

Also add the useful CMSIS core files from the latest release there:

https://github.com/ARM-software/CMSIS_5/releases

Hi, I'm working on setting up a similar minimal project for a STM32H755 (dual core). Would it be possible to get a copy of your base project to use as a reference? It would be a huge help. Thanks

NBlag.1
Associate II

My approach to the problem is to immediately open a new file, named my_main.c, and create a while (1) {} function in it. Then I have a completely blank screen and a "main loop". In the original main.c the file only has a call to my_main (). This may not be the smartest solution, but it helps me to not to look at the original main.c, which doesn't actually do anything, and is overloaded with various /*...*/,//! I don't know if anyone, whether a beginner or a pro, got a little scared when they saw the automatically generated main.c from CubeMX. That file looks like an ad that says, "Hey look what we did all for you."

Thanks,