All STM32F4 tutorials

Sometime I made a tutorial how to work with something on STM32F4xx device, because is hard and pointless to make library for it for any reason.

Tutorials are set to work with STM32F4xx devices.



Tutorials

NR Name Description
1 FIRST TIME First time with STM32F429 Discovery. Coocox project tutorial
2 KEIL UVISION Default project for Keil uVision to work with STM32F4 devices
3 PWM PWM tutorial for STM32F4xx
4 NVIC Nested vector interrupt controller tutorial
5 EXTI External interrupts tutorial
6 UART BOOTLOADER Program STM32F4 with only UART using internal bootloader on STM32F4
7 TICK DELAY Make precise delay without Systick timer, only simple variable based counter
8 PRINTF Use printf to output data to stream
9 FFT Fast Fourier Transform (FFT) using DSP libraries
10 PID PID Controller using DSP libraries
11 OVERCLOCK Overclock STM32F4 device to up to 250MHz
12 STM at FULL SPEED How to properly set STM32F4xx PLL parameters to get maximum clock
13 DISABLE IRQs How to properly disable/enable interrupts in Cortex-M processors to avoid strange behaviours in your system
14 IRQ STATUS How to know if your code is running inside interrupt mode or not (thread mode)
NR Name Description

 

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • STM32F429 with external flash memory examples please

  • krishna_kumr243

    Dear Sir, what’s the major difference between Kiel and CooCox environment??/

    • Coocox: arm gcc compiler (free), based on eclipse, free
      Keil uVision: arm compiler (not free), own IDE, not free

    • Justnfree

      Coocox is easier for beginners, but doesn’t recognize J-link debugger easily, when it does with lot of troubles doesn’t function properly.
      Keil works perfect and functions much better during debug with different debuggers. Also with Hex files smaller than 32K it’s free.

  • Jo Van Montfort

    @majerletilen:disqus Can you point me to your I2C library that is HAL compliant?

  • q3gun

    im afraid to move to STM32 from arduino -_- . But it seems to be must in the future… is there many bugs or differencies , and is it hard to ‘port’ my old arduino 328 codes on it , or does most of the codes work straight away?
    somehow i find this complicated.

    • Pretty nice to port from there. I made this too :))

      • q3gun

        oh is it ? thanks for encouragements :3

  • robotic arm

    Hey!

    I was successfully able to control the robotic arm using a mobile and adcs of stm32f4.

    Now I want to use voice commands to control the robotic arm.

    Can you please let me know if this could be done using stm32f4 and if so can you please guide me about how I can proceed?

    1)MP45DT02, ST MEMS audio sensor, omnidirectional digital microphone

    2)CS43L22, audio DAC with integrated class D speaker driver

    I found the above two features. Will they be useful in doing it?

    Thanks in advance 🙂

    • MP45DT02 might be great for you.

      You will need some filtering process (FIR, IIR) to get useful data from mic.

      • robotic arm

        Yes, I agree. But usually for speech recognition people prefer fpgas to microcontroller. I am skeptical if discovery board can do it or not.

        • You didn’t mention that.
          Well, I’ve successfully record data, filter it with FIR filter and play it back on output.
          No problems at ALL. Cortex M4 has DSP instructions so no problem for that,

          • robotic arm

            Sorry,my bad.Thanks for the assurance.Do you have any tutorial for this?

          • I have code but it is not for public use.

          • robotic arm

            Hahaha.. I need a block diagram may be.. not the code.. 😛 It is okay if you can not share.. 🙂

          • You can check STM32F4-Discovery firmware for this.

            But it goes something like this:
            – via I2S read MIC block of data,
            – filter it with FIR,
            – do what you need after filtering
            – go back again.

          • robotic arm

            Thanks a ton! That should help me to get started..:)

  • Thanh Nam Nguyen

    helo!
    you have any examples of BLDC motor control?
    I’m having trouble with controlling them, it does not rotate

  • ritesh

    hii..I have got a stm32f407 discovery board and I have to use it in my M.tech project work.
    but the problem is that I haven’t ever work on any microcontroller and I don’t know c programming, but I am very excited to work on this board.so could you tell me how should I start and what are the prerequisites, so that I could be able to write program for my project.
    thank you

  • Ernesto Mazon Valadez

    Hi, somebody know how use DAC with HAL drivers of the ST32CubeMx, but without use sin or triangle generator for STM32F4 Discovery?

    • Sure.

      • Ernesto Mazon Valadez

        Well, I set up the STM32 with STM32CubeMX, and I generated the code for Keil, but I don’t know how use DAC with this new drivers.

        • Why you need cubemx here? Did you checked examples from cube package?

          • Ernesto Mazon Valadez

            I use the cubemx because I am starting to use STM32 and with it is very simple set up the microcontroller. Yes, I checked the examples and user manual of STM32F4xx HAL drivers, but I don’t understand very well how use the “DAC_HandleTypeDef”. Only I wanna set a simple value in the DAC1. What are the steps for use this module?

          • Ernesto Mazon Valadez

            Hi, I have acomplisment to use the DAC in STM32. Thanks for help.

  • sel mesal

    Hello,

    I am exploring STM32F429I-DISCO with touchscreen LCD.
    I am interested in creating a numeric keypad that can take inputs (and store the values).

    Preferred tools I would like to understand more are SW4STM32 & emWinGUIBuilder (open to other recommendations).

    Could you point me in the direction of how to get started?

    Manny

    • Hello,

      You have all libraries you need. So start with my EMWIN library and check EMWIN datasheet on how to use it properly with guibuilder.

  • Santosh

    Hi Tilen, Can you tell me the procedure to use your STM32F4 29 library/code of Keil to be used in IAR? Sorry If you are getting this question again? – santosh

    • Not sure I understand your question. If understand OK, then just use .c libraries in IAR.

      • Santosh

        What I mean is to create IAR workplace around your library and examples . like for Kiel you have project file which opens in Kiel and just compiles . similarly I expected project files for IAR which can be opened in IAR and just compiles. You may tell me the procedure to do it.I will then convert all required Kiel project into IAR project. Sorry if it is a silly question…

  • Uthra

    Hi, How to include STemWin middleware in my SW4STM32 project (code generated from STM32CubeMx)..Thanks in advance…I tried inculding the inc files of emWin in project Includes and the lib in Linker as well but am getting Linker error..Please help..Thanks in advance..
    Am using Eclipse IDE

  • houssem

    STM32F4 with current sensor

  • abavi4

    Hi tilz0R
    As a beginner in programming(my major is power electronic) i really appreciate all your excellent works, but during the last year i cant compile even one of your codes,despite working on many projects of stm32 based on cubeMX and Keil (HAL)
    i know you are an ultimate experienced programmer but i wish u pay attention that lots of people looking something on net,are not experienced enough that they search it in internet, or at least i AM so!
    for example recently i work on 2×16 char LCD based on some one library for stm32 and i need to use 4×20 char LCD in another project, but i failed! coz i could not use ur library for that…
    Hope some day i could use ur libraries
    by the way tanks a lot tilz0R,wish u best in world

    • Hello,

      first of all it is important to know, why you failed with my lib?
      From there, we can go next.

      • abavi4

        let me explain what i did in using a 16×2 LCD lib
        i config RS,EN,D4,D5,D6,D7 in CUBEMX and then generate source code and open Keil, then i add two files to my project,also add them in my project path and include it in my main.c
        like this
        #include “STM_MY_LCD16X2.h”
        also i define these:
        #define RS 0
        #define E 1
        #define D0 0
        #define D1 1
        #define D2 2
        #define D3 3
        #define D4 4
        #define D5 5
        #define D6 6
        #define D7 7

        after that i could simply use 16×2 Lib functions
        like this
        LCD_begin4BIT(GPIOE,RS,E,GPIOB,D4,D5,D6,D7);
        LCD_print (“NimA AzaD”);
        LCD_setCursor(2,1);

        which i print my name on LCD

        i u do the same for ur library,but it cause errors in compiler

        even i start ur tutorial on Keil but its not working! it seems i dont know how to add ur libraries to my CubeMX HAL configured projects

        would u please help me to use all these fantastic libraries of urs?

        • abavi4

          Hi tilen
          finally i used ur library successfully
          i used ur template…
          01-STM32Fxxx_Keil_CMSIS_Default_Project
          add dependencies and it works,
          tnx a lot for all ur efforts in programming!

          but still i have another problem
          how can i use 2 libraries of urs,one with CMSIS and the other with HAL
          i mean this HD44780 library with ur

          Library 26- Rotary encoder on STM32F4

          i wish if u could help me,please!