Posts

Showing posts with the label Programming

How to develop STM32 with VScode? part 2/2

Image
  So far, everything was working only if you were using the same MCU as mine - STM32F405RGT. Since, arguably, not everybody is programming drones on this exact MCU, in this post I will show how to set up a project from scratch and along this way reveal a bit of the mystery of how everything works and what was the purpose of some files from a previous post. Luckily this will be the last part of this complicated process and ideally, after that, you should be able to develop any STM32-based board. Create a project structure Open the folder where you want your project and create new folders: Src , Drivers , bin , build , link . I keep the same folder structure among all projects so that I can just copy an existing one and change only MCU-specific parts. Of course, you can have different folder structures, but be aware of that and make suitable adjustments throughout this post.   Add files The next step is downloading and adding all essential files t

How to develop STM32 with VScode? part 1/2

Image
  Introduction When you start programming microcontrollers, usually you use some IDE (integrated development environment). That is convenient - you just select your board, plug it into your computer and start writing your program. But maybe someday you ask yourself: how is it possible that code from your PC is toggling LEDs on your Nucleo board? Let's summarize everything from writing code through flashing it to debugging and viewing register values. This post will discuss the integration of VScode, CMake, OpenOCD, and Cortex-Debug for STM32 development. Basic theory Firstly, you need to create your code. You can do it in every text editor e.g. Notepad, Word, Eclipse or VScode.   When you have the text (code) written in C or C++ you need to compile it -> translate a source code into machine code, bytecode which will be understandable for the microcontroller. The compiler looks for errors and optimises the final binary code (those .bin files made with zeros and ones). At this poi