Beginner’s Guide for STM32CubeIDE and STM32CubeMx


What is STM32CubeIDE? 
       
        STM32CubeIDE is an advanced C/C++ development platform with peripheral configuration, code generation, code compilation, and debug features for STM32 microcontrollers and microprocessors. It is based on the ECLIPSE™/CDT framework and GCC toolchain for the development, and GDB for the debugging. It allows the integration of the hundreds of existing plugins that complete the features of the ECLIPSE™ IDE.STM32CubeIDE integrates all STM32CubeMX functionalities to offer all-in-one tool experience and save installation and development time. After the selection of an empty STM32 MCU or MPU, or preconfigured microcontroller or microprocessor from the selection of a board, the project is created and initialization code generated. At any time during the development, the user can return to the initialization and configuration of the peripherals or middleware and regenerate the initialization code with no impact on the user code.

What is STM32CubeMX?

   
   STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 MCU 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 is automatically integrating with STM32CubeIDE.

Why STM32CubeIDE? 

👉  STM32CubeIDE includes build and stack analyzers that provide the user with useful                         information about project status and memory requirements and also have advanced                          debugging features including views of CPU core registers, memories, and  peripheral 
      registers, as well as live variable watch, Serial Wire Viewer  interface, or fault analyzer.

👉  STM32CubeMX code generator initializes only the required peripheral clocks, which in turn            saves power.

👉  The STM32Cube consists of Hardware abstraction layers (HAL) and Low level (LL) with                  consistent interfaces which are more representative and closer to the hardware and in turn,               generate faster and smaller binaries. As embedded systems are constrained devices, thus we                need to keep the firmware as small, fast and optimized as possible.

👉  The HAL abstracts away the device interface, therefore ensuring code portability across                    various STM32 MCUs.

👉  Support of ST-LINK (STMicroelectronics) and J-Link (SEGGER) debug probes .

👉  Import project from Atollic® TrueSTUDIO® and   AC6 System Workbench for STM32                  (SW4STM32)  

Installation

You can download free Software STM32cubeIDE and STM32CubeMx from ST website, for that you have to first create your login on st.com website, you can download as given below link

STM32CubeIDE  :  Download Link 
STM32CubeMX  :  Download Link 

How to program using STM32 IDE and CubeMx? 

Bluepill Board
         First of all, we have to open STM32CubeMx fist screen we can see as given below, we have to select MCU or Select Board We you have, right now We area starting we STM32f103 Microcontroller . We are using STM32f103 MCU board Blue Pill. It not included in Standard board you have to select it with MCU selector STM32F103C8T6 , given link have blue pill board specification  link





Open STM32CubeMx Application and you see First screen is as given below to select MCU



Write  STM32F103C8T6 in
part finder search box 


First of all, select system tick a System wire to download program in MCU using ST-Link programmer you can fins link here how to download program in MCU using ST-Link Programmer and debug it.


Now, Click on Tab Clock Configuration and decide which system clock do you want to use, Here, we are using external Crystal oscillator HSE.


   Here we are developing simple in-build LED Blink program to understand working of IDE and CubeMx, In-Built LED is connected to GPIO PC13 pin, put GPIO PC13 pin to output mode click on Pin Configuration tab. You can change PC13 Label, Mode, Speed and pull up/down using GPIO table.

   
  Click on Project Manager Tab and give project Name, path  and select Toolchain IDE STM32CubeIDE  than after it will generate basic structure code for your project.


  It will after say Do you want to open your project in IDE , Click on yes and your IDE will open with project.

Now open your Project in IDE you will see screen as given below

  Project folder hierarchy have two main folder Core and Driver both have include file and its source file.  Core have main file and system files.

  Source code : Write down it on While() in main.c file

      /* USER CODE END WHILE */

       HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, SET);
       HAL_Delay(10);
       HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, RESET);
       HAL_Delay(10);

    /* USER CODE BEGIN 3 */

Program Execution

     

  ðŸ‘‰First build program and On the top tool bar, click: Run > Debug > Select STM32 MCU C/C++                        Application > OK.
 ðŸ‘‰The Debug Configuration window pops up, under the Debugger tab, select the desired debug probe, in            my case: ST-LINK (OpenOCD). Click Apply and then OK.
 ðŸ‘‰The Debug Configuration window pops up, under the Debugger tab, select the desired debug probe, in          my case: ST-LINK (OpenOCD). Click Apply and then OK.

ST-Link Interface with Bluepill
I hope this was helpful. Be sure to leave your comments, questions and edit suggestions.