Skip to main content
Ken Inoue
Associate III
March 12, 2017
Question

How do I learn STM32 programing?

  • March 12, 2017
  • 13 replies
  • 3560 views
Posted on March 12, 2017 at 15:15

I'm Japanese student, so I'm poor english.

How do I learn STM32 programing? I want to learn how to use ADC, PWM, 

Interrupt handling etc. Is there document or Video/Web seminar for novice? I want documents and video that is very easy to understand.

I have 

NUCLEO-F334R8, 

Discovery kit with STM32F334C8 and 

NUCLEO-F103RB. I have installed STM32Cube MX and IAR Embedded Workbench and I can run example code. 

#how-do-i-learn-stm32 #how-to-start
    This topic has been closed for replies.

    13 replies

    Tesla DeLorean
    Guru
    March 12, 2017
    Posted on March 12, 2017 at 15:46

    I would suspect YouTube would be a good place to start.

    The Cube install has a lot of example code installed underneath it, if you have other programming and C coding experience you should review those

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    abdou si
    Associate III
    March 12, 2017
    Posted on March 12, 2017 at 16:42

    i thik you have to start programming your stm32 whith  

    https://developer.mbed.org/

       you can found a lot of exemples 
    Ken Inoue
    Ken InoueAuthor
    Associate III
    March 13, 2017
    Posted on March 13, 2017 at 02:10

    Thank you for your reply. Which should I choose mbed or HAL?

    S.Ma
    Principal
    March 12, 2017
    Posted on March 12, 2017 at 17:34

    It depends on your current know-how and past experience, known programming language and if the interest is in the C embedded programming or driving HW components from STM32. Do you have oscilloscope access?

    (Logic Analyser would be the common tool for linux user and oscilloscope for microcontoller users 

    If coming from linux background, a soft start on microcontroller could be by using Javascript or Python on STM32.

    Ken Inoue
    Ken InoueAuthor
    Associate III
    March 13, 2017
    Posted on March 13, 2017 at 02:46

    Thank you for your reply. I have written C language in class. I have used a PIC microcomputer in class. I want to make electronic circuits with STM32. For example, buck converter. Buck converter is a power conversion circuit. I have 

    oscilloscope access. I'm Windows user. How do I learn STM32 programing? 

    Thank you for taking time to reply.

    S.Ma
    Principal
    March 13, 2017
    Posted on March 13, 2017 at 11:19

    Hello Inoue, 

    Have a look at the STM32F334 Discovery board which has digital power supply HW and SW. It may be a good starting point.

    http://www.st.com/en/evaluation-tools/32f3348discovery.html

     
    ST Technical Moderator
    March 13, 2017
    Posted on March 13, 2017 at 10:52

    Hi inoue.ken,

    Welcome to STM32 community.

    As novice user, refer to this

    http://www.st.com/content/ccc/resource/sales_and_marketing/presentation/product_presentation/37/55/ff/bc/a8/71/4f/c5/stm32_embedded_software_offering.pdf/files/stm32_embedded_software_offering.pdf/jcr:content/translations/en.stm32_embedded_software_offering.pdf

    to have more idea about STM32 Embedded Software offer (feature and limitation of Cube LL , SPL, CubeHAL, Mbed ... ) 

    This will help you to decide what solution to choose.

    I recommend you to use STM32 Nucelo board is a low-cost and easy-to-use development platform used to quickly evaluate and start a development with an STM32.

    I'd highly recommend you also to have a look to these two documents, they provide guidelines on how to build and run a sample application around the STM32 Nucleo board.

    • 

    http://www.st.com/content/ccc/resource/technical/document/user_manual/1b/03/1b/b4/88/20/4e/cd/DM00105928.pdf/files/DM00105928.pdf/jcr:content/translations/en.DM00105928.pdf

    •

    http://www.st.com/content/ccc/resource/technical/document/user_manual/98/2e/fa/4b/e0/82/43/b7/DM00105823.pdf/files/DM00105823.pdf/jcr:content/translations/en.DM00105823.pdf

    STMicroelectronics STM32 families of 32-bit ARM® Cortex® -M core-based microcontrollers are supported by a complete range of 

    http://www.st.com/ja/development-tools/stm32-software-development-tools.html?querycriteria=productId=SC2106

    .

    You may have a look to the 'Getting started' manuals which allow you to go step by step to install tools and start your project.

    Regarding the way to start in order to develop your application, you have various choices:

    To have idea about mbed and supported features, you can have a look on mbed docs, cookbook.

    More that, you may find on

    http://www.st.com/content/st_com/en/support/learning/video-page.html?q=STM32&page=1

    many videos about STM32.

    Hope this helps you

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Henrik Sandaker Palm
    Associate II
    March 16, 2017
    Posted on March 16, 2017 at 18:51

    I've had great help from this book/e-book:

    Mastering STM32

    A step-by-step guide to the most complete ARM Cortex-M platform, using a free and powerful development environment based on Eclipse and GCC

    https://s3.amazonaws.com/avatars.leanpub.com/avatars/546701/tiny/io1.jpg?1445068020

    https://leanpub.com/u/carminenoviello

    https://leanpub.com/mastering-stm32

    richard239955_stm1
    Associate III
    March 16, 2017
    Posted on March 16, 2017 at 18:58

    I suggest that you choose a small project to get you started. Not complex. A single goal. As a suggestion, a 5 kHz square wave, with a 30% on and 70% off duty cycle. Your second project could be more ambitious, possibly responding to a high to low event with an interrupt that signals the event by turning on an LED.

    There are two free tools that you can write this code with, Atollic True Studio or SW4STM32 (System Workbench for STM32) AC6. True Studio has the advantage that when you upgrade to the Pro version, your code does not need to be modified for a different tool.

    STM32Cube set's up all of the complex clocks inside the STM32 device for you, and is a good starting point. There are numerous example code samples and projects within each STM32Cube Library for each of the STM32 chips, you ca examine these to see how things are done.

    The very first code sample I created was on the STM32F4 Discovery board, flashing the LEDs at different rates, and responding to the blue pushbutton.

    I wish you the best, the STM32 family is a solid blending of ARM and Peripherals.

    andy b
    Senior
    March 16, 2017
    Posted on March 16, 2017 at 20:08

    Hi

    A lot of these answers are really good suggestions.One thing that you shouldn't forget is to get familiar with your IDE stick with what you know.IAR is a great IDE for STM32 especially with the cube.It's easy to shoot code in your board and the debugger is simple to use.I suggest you really play with your IDE .Look at some tutorials to learn how to use it properly if you find you are struggling to do certain things.This will help you a lot when starting to learn how to program your STM32 and when you are troubleshooting your code.

    Best of luck to you .Wish you a lot of succes.

    -Andy
    richard239955_stm1
    Associate III
    March 16, 2017
    Posted on March 16, 2017 at 20:57

    I read, 'I'm Japanese student', and translated that to little to no money, kinda like me, so I said, free sounds good, especially for learning.

    When I know I will make a lot of money, then I will purchase something like 'fill in the blank' a very expensive tool.

    The

    https://www.iar.com/buy/

    does not show a price and that usually means $20,000 per year or more as I read it, which is a bit beyond most students. Fortunately, there are less expensive tools to use as a beginner.

    I also read 'How do I learn STM32 programing', and translated that to, it's big, a huge amount to learn, it's overwhelming, where to start, any suggestions, and put up some really small stuff to begin and gain some confidence. I gave specifics, cause I know that's what I would want.

    Dave Jones
    Associate III
    March 16, 2017
    Posted on March 16, 2017 at 23:14

    I have a different board, but the way I started was to download the STM32Cube Firmware package for my processor. It's basically a big folder full of examples that are ready to compile and upload to your board. You can try them out and then modify them to learn how they work and how to make changes to them. I find that a good way to explore a new processor.

    Alan Chambers
    Associate III
    March 17, 2017
    Posted on March 17, 2017 at 10:34

    グループ�よ���。

    I learnt by creating small projects on an STM32F4 Discovery board. I started with an empty main() and

    looked for examples in this forum. The examples were all using the Standard Peripheral Library.

    If I were doing it now, I'd get a Discovery board (or something similar), install the free edition of IAR's

    Embedded Workbench (or Keil or whatever tool you like), and install STM32 CubeMX.

    CubeMX will generate a working program straight from the GUI. This code will use the HAL library. Personally,

    I regard the HAL as significantly inferior to the SPL, and I think the generated code is scruffy and hard to understand. But

    it does work, and is a useful guide.

    I advise you to step through the code slowly to learn what it is doing with the hardware registers. At the end of

    the day, understanding a particular processor family is about understanding the registers and the core architecture, and

    the particular software library that you use is a personal choice.

    I would also spend some time reading about the Cortex-M3/M4 architecture. There are some good books on this topic

    which are not related to the STM32, but explain a lot of what is going on inside the processor, such as how SVC calls

    are used to implement an OS, how interrupts work on this hardware, and so on.
    LMI2
    Senior III
    March 17, 2017
    Posted on March 17, 2017 at 17:55

    When you look the  code Cube generated, you'll get files for ADC and serial bus and so on, if you enabled them in Cube.  Look closely what files there are and what is in them. Like:                    

    HAL_ADC_Start(& hadc1);

                                        while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))

                                        {

                                        }

                        ccc= HAL_ADC_GetValue(&hadc1);

    You can then search for those function names with Google. There are a lot of blogs and web sites about programming STM32F devices with CUBE. and you will find examples showing how to use the functions.

    Getting ADC and UART to work is not too difficult. Ethernet and USB probably is.

    A Discovery board is better in my opinion because it was easy get every CPU pin out off board.