Author Topic: STM32f4 Example codes  (Read 9302 times)

0 Members and 1 Guest are viewing this topic.

Offline ulixTopic starter

  • Regular Contributor
  • *
  • Posts: 87
  • Country: de
STM32f4 Example codes
« on: July 14, 2017, 01:07:37 am »
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
« Last Edit: July 14, 2017, 01:15:16 am by ulix »
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32f4 Example codes
« Reply #1 on: July 14, 2017, 09:24:36 am »
Could anyone direct me to the code examples?
You can either directly download the relevant Cube package for your MCU(s), or have it downloaded by the CubeMX initialization 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.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: STM32f4 Example codes
« Reply #2 on: July 14, 2017, 09:29:42 am »
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.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: STM32f4 Example codes
« Reply #3 on: July 14, 2017, 09:30:45 am »
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.
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32f4 Example codes
« Reply #4 on: July 14, 2017, 10:12:11 am »
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.
Mastering STM32
It'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.

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.
Oh, the joys of ST documentation ;).
Let's take the documentation for the very basic STM32F411 Nucleo64 board:
  • The generic Nucleo64 User Guide, good for all of them.
  • The so called Datasheet, 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.
  • The Reference Manual, complete information on each peripheral, register and memory maps. For this relatively simple MCU, 837 pages.
  • The Programmers 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 the Errata! 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  :popcorn:), and delving into details is not always needed.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline ulixTopic starter

  • Regular Contributor
  • *
  • Posts: 87
  • Country: de
Re: STM32f4 Example codes
« Reply #5 on: July 14, 2017, 05:43:51 pm »
Thanks a lot for this great advice!

I have worked with Freescale/NXP ARMs and have some stm32 disco boards and nucleos.
 

Offline julian1

  • Frequent Contributor
  • **
  • Posts: 734
  • Country: au
Re: STM32f4 Example codes
« Reply #6 on: July 15, 2017, 01:00:41 am »
 

Offline ulixTopic starter

  • Regular Contributor
  • *
  • Posts: 87
  • Country: de
Re: STM32f4 Example codes
« Reply #7 on: July 16, 2017, 09:10:32 am »
There are no examples for programming directly the registers?

I wouldn't want to use all this lib stuff...
 

Offline nugglix

  • Regular Contributor
  • *
  • Posts: 209
  • Country: de
Re: STM32f4 Example codes
« Reply #8 on: July 16, 2017, 09:40:02 am »
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.
 

Offline ulixTopic starter

  • Regular Contributor
  • *
  • Posts: 87
  • Country: de
Re: STM32f4 Example codes
« Reply #9 on: July 16, 2017, 11:07:40 pm »
 :-X
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 :box:
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: STM32f4 Example codes
« Reply #10 on: July 17, 2017, 08:31:08 am »
If you don't like that, add a smiley.
::)

:-X
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 :box:
Unfortunately 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.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Gibson486

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: us
Re: STM32f4 Example codes
« Reply #11 on: July 25, 2017, 12:29:02 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf