Posts

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

USB with STM32

Image
  USB - basic description: USB is probably the most common interface nowadays. Possibly due to the versatile protocol which can handle many different peripherals: flash drives, printers or keyboards... Also, it is self-configuring (no data format or speed needs to be selected), reliable (no data lost during transfer), and pretty fast. Since this protocol is so versatile software is not simple and it's not trivial to implement it on your own. Fortunately, this is also a reason why there are ready-to-go libraries for this protocol which takes care of all complicated and specific aspects of implementation. In this post, I want to show how to use the STM library for USB and how to modify it to use more than just one class - create a simple "composite" device. How to get STM32 Library: For USB there is always one host and one or more devices connected to it. STM can be programmed as both but for now, we will discuss only the device option. Because the USB standar