Dive In Deep with the Mandelbrot Set Using an STM32 Microcontroller

The Blue Pill Mandelbrot can zoom into the complex boundary using an STM32, tiny RGB display, and OpenOCD.

Cabe Atwell
3 years agoDisplays

The Mandelbrot set is described as a mathematical function that’s generated by iteration or repeating a process over and over again. In this case, it produces a heart-shape with an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive detail at increasing magnifications, which makes the Mandelbrot set a fractal curve. In other words, it creates the same infinite pattern when zooming into any location on its edge. It also makes an excellent benchmark for computers.

Embedded software engineer Athanasios (Thanassis) Tsiodras has managed to run the set on many different hardware platforms using varying methods, with his latest utilizing a 32-bit STM32F103C8 microcontroller. Dubbed the Blue Pill Mandelbrot (because he had yet to utilize a microcontroller), the platform also uses a 16K IPS display and utilizes a few memory tricks to get the zooming function to roll, as the STM32 only has 20Kb of RAM available.

The integer multiplication was also difficult to pull off, as the continuous zoom function is tricky to employ on such as small packages, so it’s limited to fixed-point multiplication, meaning there’s only so many times you can zoom in on a fixed point.

“The ‘entireScreen’ template parameter is evaluated at compile-time; the ‘mandel’ function basically exists conceptually in two forms: one computing two 80x80 windows and SPI-ing them, in turn, to render on the entire screen, and one with a single 80x80.," Tsiodras explains. "To decide which form to build, the ‘Makefile’ has two targets: ‘make small_screen’ (default) and ‘make big_screen.’ In the ‘small_screen’ mode, I also added a frame rate counter, where we see that we start at around 10 frames per second (FPS) and after zooming 1600 times in the middle of a Mandelbrot lake, we are at 1 FPS.”

Tsiodras has uploaded the code for the Blue Pill Mandelbrot on his GitHub page for anyone who would like to recreate his project.

Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles