Programming STM32 "blue pill" with HAL and Eclipse
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.
CH341A SPI Programming (Windows API)
CH341A is used by some cheap memory programmers. The IC is somehow limited in this configuration, because the programmer makes use only of the SPI and I2C interface. A popular device is the so-called "CH341A MiniProgrammer" that you can buy for 2 to 5 USD. And this is probably the cheapest device using CH341A.
If you got a "MiniProgrammer", you may want to use for more than memory chips programming. The device can actually be used as USB to SPI converter (not only SPI, but this article will focus only on SPI function). Let's see how to use the included library and header to communicate with SPI peripherals.
CD4017 and NE555 Light Chaser Circuit
NE555 is configured as an astable multivibrator. Oscillation frequency is rather low for this application. It is determined by R1, R2+RV1 and C2. With the values used for this circuit, it can be adjusted between 10 and 65 Hz. The duty cycle is close to 50%. If you want to calculate it yourself, use this tool.
Drive stepper motors with Arduino (code)
A stepper motor is a brushless electric motor that rotates in small equal steps, as opposed to the continuous rotation of regular motors. It has the ability to rotate a predefined number of steps, being made of multiple coils that are energized in regular sequences by trains of digital pulses. Unipolar motors use two coils, each of them having a center tap. The center taps from both coils connect to a power line and the remaining four coil terminals are powered sequentially (they have at least 5 wires). On the other hand, bipolar stepper motors have two coils that are powered one after another then voltage polarity is reversed and coils are powered again (this type of motors have only 4 wires).
A simple transistor driver and connections (only for unipolar steppers) and driving methods were discussed in the previous post: Driver and Arduino code for unipolar stepper motors. Some basic Arduino functions were provided there. But those functions are too basic for most usage scenarios. The motor can be driven only in with multiples of 4 or 8 steps and you can't change rotation direction. In this post, I will explain further the driving methods and I will generate driving pulses programmatically, with the ability to move one step at a time and change the rotation direction.