Showing posts with label STM32. Show all posts
Showing posts with label STM32. Show all posts

Alternative firmware for XTW100 Programmer

 Posted by:   Posted on:    4 comments

I have bought the XTW100 Mini Programmer and while attempting to read the firmware of the STM32 MCU using an ST-Link programmer, somehow I erased the flash and got a totally useless piece of hardware. XTW100 is advertised as a better replacement for the CH341A based programmers and after tracing the schematic I failed to find any reasons why it should be better. The information I gathered can be found here.

With the original firmware, the programmer should be able to interface SPI and I2C EEPROMs and flash memory chips. However, since I have no way of getting that back to test whether the programmer works or not, I found there is an open-source firmware available. Unfortunatety, it does not come with I2C support.

Alternative firmware for XTW100 Programmer

USB multimedia keys on Arduino STM32

 Posted by:   Posted on:    6 comments

I switched from a keyboard with media controls to a new one without such functionality. Then I realized I was missing the volume and play/pause buttons from the old keyboard. But I have some development boards which I could use to control media and PC volume. I've seen some projects using the Bluetooth functionality of ESP32 to emulate a keyboard. But for now, wired USB interface is what I want. The cheapest and most capable board for this purpose is the STM32 "bluepill". Although I'll end up buying another keyboard with multimedia buttons sooner or later, now I'm going to program the STM32.

I thought this would be easy. But there are multiple ways of programming this ARM microcontroller. It can be done with STM32 HAL. But I found it hard to develop the USB HID device. I looked for something easier. With the Arduino IDE, you have access to two development kits, one from STmicroelectronics and another one from Roger Clark (which is based on libmaple). I attempted to use the official package from ST, but their USB library only supports a basic keyboard (same as Arduino Keyboard library). I found that the other package, from Roger Clark, supports USB Consumer HID. Although it is based on old libmaple it still works. I decided to work with the official package though.

USB multimedia keys on Arduino STM32

USB multimedia keys with STM32 on breadboard

Program "blue pill" with STM32 Cores in Arduino IDE

 Posted by:   Posted on:    5 comments

Back when I wrote Set up STM32 "blue pill" for Arduino IDE I found two Arduino Boards packages for STM32. I didn't know at that time what were the differences between them and that post uses the STM32 package developed by Roger Clark. In fact, that one originates from libmaple which was first developed by LeafLabs for their Maple boards. The library was written in 2012 and it is no longer under active development.

I consider STM32duino to be a better alternative now, since it is actively developed by STMicroelectronics and uses as backend recent versions of STM32 libraries (LL, HAL). More than that it has support for multiple cores and boards including, but not limited to, official evaluation boards, 3D printer boards and flight controllers. To be able to use it you need a board and a programmer, Arduino IDE and STM32CubeProgramer. Fortunately the required software is cross-platform so you can code for STM32 on any platform. In this post I'll show you how to install the required software and how to upload sketches to STM32 "blue pill".

Program blue pill with STM32 Cores in Arduino IDE

External interrupts on STM32 bluepill

 Posted by:   Posted on:    No comments

The bluepill is a cheap STM32F103 development board. It can be programmed even from Arduino IDE with an additional boards package. But to get the most out of it, you should develop software using the development kit from ST. This is because STM32 is much more complex than ATmega microcontrollers used by some Arduino boards. While the latter are use 8 bit CPUs, STM32F103 contains a 32 bit ARM Cortex CPU.

It's not my first attempt to program the STM32 bluepill using HAL library from ST. This post contains information about the tools you need to install in order to program the board. I'm going to make a new project in System Workbench and I will use the same clock configuration routine from the mentioned post (the SystemClock_Config() function). Then I will write code that toggles an LED when you push a button using interrupts.

STM32 bluepill on the breadboard

STM32 bluepill on the breadboard

Upload binary and debug STM32 bluepill on Eclipse

 Posted by:   Posted on:    3 comments

The blue pill is a STM32 development board which can be programmed in multiple ways. You can use Arduino IDE, mBed OS or HAL library from ST. This post is about STM32 development using HAL. There is a plugin for Eclipse that adds features for working with this family of microcontrollers (MCU) and there is also System Workbench for STM32 (SW4STM32), a complete development environment based on Eclipse IDE.

In a previous post I talked about STM32 development on SW4STM32. At that time I was just beginning with this MCU and after I was compiling the project binary, I used ST-Link tools to upload it to the board. That worked, but it was uncomfortable to launch ST-link utility or call st-flash after each build. More important, I lost all debug options with this method. I didn't knew then that Eclipse/SW4STM32 can be configured to automatically upload (burn) binary to MCU and debug it. Configuration procedure is a one-time process per project.

Upload binary and debug STM32 bluepill on Eclipse

Truly LCD front panel: the backlight

 Posted by:   Posted on:    No comments
Here is the follow-up of the post where I described how I took out the front panel of a router (yes, a router) and found a way to interface it with Arduino or other development board. It should be noted that the front panel electronics use 3.3V levels, therefore the popular 5V Arduino boards cannot drive the front panel. Using level shifters would complicate things and increase the possibility of something going wrong, so I ended up using a 3.3V STM32 blue pill development board. This is programmed from Arduino IDE, so the code I write is compatible with Arduino development boards.

While I was sampling various pins of the front panel connector with a logic analyzer, I noticed a strange protocol on pin 18. I was able to trace the PCB track from pin 18 near an area that seemed like a DC-DC converter. It directly drove an integrated circuit marked T43. Searching for it revealed some LDO linear voltage regulators, but this was not the case. Pin 18 carried a digital protocol that would be of no use for an ordinary voltage regulator. But without information I could only write code that would mimic the protocol I sampled. Things changed once the GPL source code has been made public. The signal on pin 18 had a meaning. It was necessary to turn on/off and dim the backlight. Upon powering the front panel on the breadboard, the backlight stayed off. You can turn it on by setting pin 18 high but if you want to adjust its level you must send two bytes using a custom serial protocol. Before getting to the code let’s see an overview of the pins and connections on the breadboard.

Front panel connector adapter on breadboard
Front panel connector adapter on breadboard

STM32Cube code initialization for “blue pill”

 Posted by:   Posted on:    8 comments
Lately I’ve playing around with the STM32F103 development board known as “blue pill”. Developing software for it is not as easy as for Arduino boards. The MCU contains a 32-bit ARM CPU. I have previously tried to write software for this board using HAL library, but I didn’t get the most out of it because I found the programming model rather complicated.

One of the methods to develop software for this MCU is to use ST HAL library (which uses a higher level API than other libraries for this MCU). I chose the Eclipse IDE with a set of plugins for STM32 family. There is an easier way to get the SDK and IDE with the toolchain called System Workbench for STM32 (recommended by ST too). This is the download directory where you can find all releases for the major operating systems. But before creating a blank project in SW4STM32, you should know that there is a tool which can create this project for you. Not quite blank, as you will configure the MCU with a graphical tool in a step-by-step process.

STM32Cube code initialization for “blue pill”

STM32 “blue pill” easy development with Mbed

 Posted by:   Posted on:    7 comments
The "blue pill" is an STM32F103 based development board. Although it is less popular, the board is cheaper than an Arduino Nano. More than that, STM32F103 is a device with Cortex-M3 ARM CPU that runs at 72 MHz, 20 kB of RAM and 64 or 128 kB of flash memory. The microcontroller (MCU) has USB port, two serial ports, 16 bit PWM pins and 12 bit ADC pins. It runs at 3.3V, but some of its pins are 5V tolerant.

I tried to program this development board using both Arduino IDE and STM32 HAL, but I wasn’t quite satisfied. Arduino framework is simplified and does not take advantage of platform’s features, while HAL was quite difficult for me. Using HAL in Eclipse come with another disadvantage: direct uploading of the binary in flash didn’t work, so I had to use ST-Link tools to upload it, outside of Eclipse. Recently I heard of PlatformIO IDE. This is a development environment supplied as Visual Studio Code or Atom plugin. One of its great advantages is the support for more than 500 development boards! Although VS Code and Atom are cross platform software, they are not at all lightweight, so you’ll need rather good hardware to run them smoothly.

Another great feature of PlatformIO is that for a development board you have multiple framework options. You can program the bluepill using Arduino API, just as you would do in Arduino IDE. Or you can program it using STM32Cube API. But, there is also Mbed OS framework, which I found it to be quite easy to develop.

STM32 “blue pill” easy development with Mbed

Programming STM32 "blue pill" with HAL and Eclipse

 Posted by:   Posted on:    9 comments
The "blue pill" is an STM32F103 based development board. Although it is less popular, the board is cheaper than an Arduino Nano. More than that, STM32F103 is a device with Cortex-M3 ARM CPU that runs at 72 MHz, 20 kB of RAM and 64 or 128 kB of flash memory. The microcontroller (MCU) has USB port, two serial ports, 16 bit PWM pins and 12 bit ADC pins. It runs at 3.3V, but some of its pins are 5V tolerant.

Unfortunately programming this board is not as easy as programming an Arduino board. There is a project named STM32duino aimed at simplifying things which makes use of Arduino IDE and similar programming language. But, STM32 is a complex CPU with more functions than Arduino language offers. You can program it using Eclipse IDE and a set of libraries offered by ST. These libraries are LL (low level), StdPeriph (standard peripheral library) and HAL (hardware abstraction library). HAL uses high level API which simplify developing an application. This post will show you how to configure the development environment and write the first program with HAL that will blink an LED.

An easier alternative to Eclipse and HAL is PlatformIO and Mbed. Check it out.
Programming STM32 "blue pill" with HAL and Eclipse

Set up STM32 "blue pill" for Arduino IDE

 Posted by:   Posted on:    16 comments

The "blue pill" is a STM32F103 based development board. Although it is less popular, the board is cheaper than the Arduino Nano. More than that, STM32F103 is a device with Cortex-M3 ARM CPU that runs at 72 MHz, 20 kB of RAM and 64 or 128 kB of flash memory. The microcontroller (MCU) has USB port, two serial ports, 16 bit PWM pins and 12 bit ADC pins. It runs at 3.3V, but some of its pins are 5V tolerant.

Programming the board can be simplified using the popular Arduino IDE. But before this, an Arduino-like bootloader must be flashed to the board. This can be done via serial port or using the debug interface of the MCU with ST-Link tool. There are also some small hardware issues with Chinese boards that need to be fixed. This post will show a straightforward guide for setting up this board to work with Arduino IDE on Linux and Windows. The instructions below are based on STM32duino wiki [down?] documentation.

Important! There is now an officially developed Arduino STM32 boards package from STMicroelectronics. It is based on HAL and LL libraries. It is recommended to use that one instead. Please follow instructions from Program "blue pill" with STM32 Cores in Arduino IDE.
Set up STM32 "blue pill" for Arduino IDE