STM32f4 Example codes - Page 1
Forum section: electronics / general

author: ulix
author_rank: Regular Contributor
timestamp: July 14, 2017, 01:07:37 am
content: Hi,I want to get started with stm32f4 mcus, but somehow I'm not able to finde some code examples for this mcu series.There should be some stm32f4xx.h lib, which is available for the stm32f0.Could anyone direct me to the code examples?Thank you

author: newbrain
author_rank: Super Contributor
timestamp: July 14, 2017, 09:24:36 am
content: Quote from: ulix on July 14, 2017, 01:07:37 amYou can either directly download the relevant Cube package for your MCU(s), or have it downloaded by theCubeMXinitialization code generator.CubeMX is quite handy if you are starting out.Once the Cube SW is on your local machine, the example projects are located (e.g. for the latest F0 Cube) in:<path to your repository>\STM32Cube_FW_F0_V1.8.0\Projects.The examples (use of the HAL/LL and periipherals) and the "Applications" (use of middlewares as FreeRTOS, USB lib etc.) projects are subdivided by board type, but they are easily portable: that's the whole point of the frameworks.

author: Kjelt
author_rank: Super Contributor
timestamp: July 14, 2017, 09:29:42 am
content: Easiest steps to start is buy a recent (nucleo) F4 discovery board, it has the STLink debugger built in.Join the STM32 community forum so you can read what others already stepped in to (their problems could be your problems).Download CubeMX read how it works, select first only one or two peripherals to get started and generate the startup code.Run this code in the SW4STM32 IDE environment , compile and run.Oh yeah download the datasheets of the processor on the nucleo board, family reference manual, and other relevant documentation from st and start reading what you need.Depending on previous experience this could be done in less than 1 day upto 2 days and you should have a blinky and simple uart working.

author: Kjelt
author_rank: Super Contributor
timestamp: July 14, 2017, 09:30:45 am
content: Oh yeah and if you are totally new you might want to purchase the STM32 E-book from the italian guy, cant find the link now but search the forum it will show up.

author: newbrain
author_rank: Super Contributor
timestamp: July 14, 2017, 10:12:11 am
content: Quote from: Kjelt on July 14, 2017, 09:30:45 amMastering STM32It's AFAIK, quite well considered (I don't have it).It also describes step by step how to set up a complete toolchain, an alternative to pre-packaged IDEs.Quote from: Kjelt on July 14, 2017, 09:29:42 amOh, the joys of ST documentation.Let's take the documentation for the very basicSTM32F411 Nucleo64board:The genericNucleo64 User Guide, good for all of them.The so calledDatasheet, that contains a brief description of the various peripheral and chip specific information (DC and AC characteristics, pinouts, alternate functions pin assignments etc.) 149 pages.TheReference Manual, complete information on each peripheral, register and memory maps. For this relatively simple MCU, 837 pages.TheProgrammers Reference, mostly a rehash of ARM information. I've seldom needed this, but its 260 pages contain details of the NVIC, Systick and other ARM generic information for F3, F4 and L4.Never, ever, forget to look at theErrata! At least it's usually quite short.And then there tons of ANs and guides and library documentation (the HAL one is useless to me, I prefer reading the doxygen source along with the code in a good IDE.It might seem a bit daunting clocking in at more than 1000 pages for a middle of the road MCU, but I personally find the docs to be of good to very good quality (many are bound to disagree), and delving into details is not always needed.

author: ulix
author_rank: Regular Contributor
timestamp: July 14, 2017, 05:43:51 pm
content: Thanks a lot for this great advice!I have worked with Freescale/NXP ARMs and have some stm32 disco boards and nucleos.

author: julian1
author_rank: Frequent Contributor
timestamp: July 15, 2017, 01:00:41 am
content: f4 examples for the libopencm3 libraries,https://github.com/libopencm3/libopencm3-examples/tree/master/examples/stm32/f4/stm32f4-discovery

author: ulix
author_rank: Regular Contributor
timestamp: July 16, 2017, 09:10:32 am
content: There are no examples for programming directly the registers?I wouldn't want to use all this lib stuff...

author: nugglix
author_rank: Regular Contributor
timestamp: July 16, 2017, 09:40:02 am
content: If you can use the registers directly, you don't need any "examples" anymore.If you need "examples", you shouldn't use direct register access.If you don't like that, add a smiley.

author: ulix
author_rank: Regular Contributor
timestamp: July 16, 2017, 11:07:40 pm
content: How should I learn...?In the ref. manual is for example is: GPIOx_OTYPER but it'S used like GPIOx->OTYPER.For this special things I wanted examples...If there is nothing, it's ok. Will fight my way through

author: newbrain
author_rank: Super Contributor
timestamp: July 17, 2017, 08:31:08 am
content: Quote from: nugglix on July 16, 2017, 09:40:02 amQuote from: ulix on July 16, 2017, 11:07:40 pmUnfortunately I don't know of any good examples for that.I learnt my way going through the HAL source code...once one see through all the extra stuff, the information is there.Of course reading the docs is then even more important.

author: Gibson486
author_rank: Frequent Contributor
timestamp: July 25, 2017, 12:29:02 pm
content: I just used their HAL API (yes, suffered through it). Once you get it working, you see what you think you can do better and go from there.