Kyle
Kyle

Reputation: 330

Where should I get the header files for an STM32 microcontroller?

I have this STM32F3 Discovery board, and I'm trying to flash a simple blink program to it. All of the examples I've found have several stm32*.h header files, such as this for an F4 Discovery board tutorial:

#include "stm32f4xx.h"
#include "fm_stm32f4_led.h"
#include "fm_stm32f4_delay.h"

Where and how do I get the header files for my board? (STM32F3) I can't seem to find anything in the datasheet or documentation to point me at where to get them. Also, what would be a good source for examples and learning material?

Upvotes: 5

Views: 10216

Answers (2)

veeman
veeman

Reputation: 800

Like Lee Daniel Crocker mentioned all HAL libraries shipped with the STM32Cube initialization code generator. You can download it here:

https://www.st.com/en/development-tools/stm32cubemx.html

Also you can simple download only the HAL library sources: STM32CubeF3, STM32CubeF4

Moreover the header files fm_stm32f4_led and fm_stm32f4_delay are some custom implementations from your tutorial. The associated code is probably this one: https://github.com/RoanFourie/STM32F4-DISCO-EMBITZ-Blinky/tree/master/STM32F407Disco/LED

Therefore there is no F3 header/source files for this example. Anyway it should be easily reused or ported for the F3.

Upvotes: 1

Tarick Welling
Tarick Welling

Reputation: 3265

Firstly you have a STM32F3 discovery board this means that the stm32f4xx.h header is the wrong one. You'll need the stm32f3xx.h. Also tutorials for a F4 microcontroller will need to be interpreted to be useful for a F3. Some features of a F4 are not present on a F3.

You can download the headers/library for the STM32F3 from ST.com using a ST account. The page you linked to contains a section called Embedded Software which contains a link with the text: STM32CubeF3. Following through the redirections you'll get an opportunity to download the library by clicking: Get Software.

This contains a complete project structure for several boards.

You can also download STM32CubeMX. This "is a graphical tool that allows a very easy configuration of STM32 microcontrollers and microprocessors, as well as the generation of the corresponding initialization C code for the Arm® Cortex®-M core or a partial Linux® Device Tree for Arm® Cortex®-A core), through a step-by-step process." It allows you to generate new projects and lets you easily included required (or all) library files.

fm_stm32f4_led.h and fm_stm32f4_delay.h are header files created by RoanFourie and are meant to target a F4 board. I suppose they are not that useful for you.

I can recommend this tutorial from an ex professor of mine. It is targeted at the F0 microcontroller and uses Keil but the general rules still apply. You'll have to figure the ports and pins out for yourself though.

Upvotes: 2

Related Questions