Getting started with projects based on STM32G071RB Board using STM32CubeIDE

Getting started with projects based on STM32G071RB Board using STM32CubeIDE

Check out our Control Board!

Getting started with a 32-bit ARM-based microcontroller is always a little daunting. There are too many of available microcontrollers, platforms, development boards, tools, and software. This note describes step by step how to begin a LED project.

Getting started: about Development Board STM32G071RB

Features:

  • Core: Arm® 32-bit Cortex®-M0+ CPU, frequency up to 64 MHz
  • Up to 128 Kbytes of Flash memory, 36 Kbytes of SRAM
  • 7-channel DMA controller with flexible mapping
  • 12-bit, 0.4 µs ADC (up to 16 ext. channels)
  • Two 12-bit DACs, low-power sample-and-hold
  • Two I2C, Four USARTs , one low-power UART , two SPIs

 

Getting started: Install STM32CubeIDE

You can download STM32CubeIDE from their st.com.  It’ s free. Install STM32CubeIDE following STM32CubeIDE installation guide.

 

Your first project: LED blink

Before we can start writing code we need to create a project. This is similar to most other IDEs – projects are used to bundle together all of your settings, code, and definitions into a single collection all managed from the same application.

 

 

STEP 1: Start a new project, From the top left icon ( Or under the menu File > New > STM32 Project) to get started.

 

Step 2: Project name: G0_LED, then click Finish Button.

From schematic diagram that the LED4 is controlled by STM32G071 and the port is PA5.

Step 3: From System Core > SYS, select Serial Wire, setup PA5 as GPIO_OUTPUT.

Setup use label for PA5 as LED_GREEN as below:

 

Step 4: Then Generate code.

 

CubeIDE, which this functionality is developed upon, generates C files to work with under a Src directory, and puts a HAL (Hardware Abstraction Layer) into an Includes directory. It appears CubeIDE works the exact same way. Expand the folders on the right under the project view and see what it has generated to work for you.

 

 

Step 5: Let’ s add a smidge of C code of our own now! After the Infinite Loop area, we’re going to add code to toggle the LED under section 3 as below:

 

 

Compiling the project and downloading it to the board

STM32CubeIDE actually makes it pretty easy to compile our work and get it onto the STM32 chip.  The first step is to produce the compiled .elf ( a binary version of our code).  To generate the .elf, we need to do a build. This is as easy as pressing the build button on the toolbar.

Now, build information is presented in the console at the bottom of the screen.

Now what we want to do is send this compiled binary onto the STM32 microcontroller.

Let’s plug in the dev kit:

The Red power LED (to the left of the blue switch) is lit, as is the larger communication LED (by the USB cable). Inside STM32CubeIDE, select the run button.

This will open the Run dialog ( as it’s the first time we’ve run it). The settings we choose now will be saved as a run configuration which we can re-use or edit later.

Simply press Apply and then OK and the download will proceed. The Console will now fill with some interesting text:

The LED is on and off every 500ms. you’ve got everything set up.

STM32 vs Arduino

STM32 vs Arduino

Check out our Control Board!

 

Arduino

Arduino is more creative, it weakens the operation of specific hardware, its functions and syntax are very simple, and it is very “dumb”.

Most of Arduino’s main control is AVR microcontroller. The advantage of Arduino is that it has high code encapsulation and fewer sentences, which reduces the difficulty of software development.

Arduino is relatively easy to get started, as long as you understand a little hardware and C++, you can develop.

Most of the functions of Arduino have well-built libraries, so it is very simple to use, but the controllability of slightly more complicated functions is poor. 

 

STM32

STM32 pays more attention to engineering practice. In fact, there are many simple instruments in the factory, such as temperature controllers, ordinary motor controllers, low-end PLCs, and some civilian toys, game controllers, wired keyboards and mice, and other peripherals and so on are very practical.

STM32 is mainly used as products for professional developers, which requires certain professional knowledge, but at the same time, it is relatively complicated to write code to realize functions. For example, the serial port outputs a simple string. For Arduino, it may start from a new project and it can be realized with 10 lines of code. However, if you use STM32 development tools such as Keil, it may require hundreds of lines of code or more.

In terms of open source: things made with STM32 can be open source if you want to open source, and you can not publish anything if you don’t want open source.

 

Conclusion

 

Here are some suggestions for choosing:

If you are an ordinary student below the university level who does not have a deep understanding of programming languages, it is recommended to get started with Arduino. If the C skills are weak and come up with STM32, you will soon have the idea of giving up.

If you only study for employment, decisively STM32 microcontroller.

If you are learning just for fun and you are not a major in electronics and have no confidence, Arduino is recommended.

If you have good programming skills, STM32 is recommended. After you get it done, you can take a look at the things made by the Arduino open-source community, and you can easily get it done with STM32.

Of course, if you have the ability, you can make contact with both. Generally, you can master the basic features of Arduino in less than a week. If you need it in the future, you can freely transplant the Arduino code to MCU platforms such as STM32.

In fact, the two are actually aimed at slightly different directions. Arduino is the choice of general electronics hobbyists and DIY, while STM32 is often used for the development and manufacturing of actual products.