Fast string to integer conversion (C/C++)

This article presents a few fast and lightweight implementations of conversion from ASCII string to integer. It can be an interesting fit to use in a small microcontrollers like for example ATtiny13, which resources are very limited. All presented functions are simplified and require a null-terminated array of chars as an argument. Convert string to … Read more

Fast string comparison for microcontrollers (C/C++)

This short article presents trivial but fast and memory efficient function to compare two strings. Function returns “0” (zero) on success (strings are the same), otherwise function returns the position where different characters occurred. Example code #include <stdint.h> #include <assert.h> static int8_t xstrcmp(const char *s1, const char *s2) { while(*s1 != ‘\0’ && *s1 == … Read more

Twiddle-factor-based DFT for microcontrollers

This version of DFT algorithm has been tested with success on a various microcontrollers (AVR – including ATtiny13, STM32 and ESP8266). The code is relatively simple and short what makes it easy to port to other programming languages / microcontrollers. In this tutorial I will open the black-box and show you some practical information about how this algorithm works and how to use … Read more

ATtiny13 – PI metal detector

This experimental project shows how to build a simple PI (Pulse Induction) metal detector based on ATtiny13 / AVR microcontroller. My goals were to make a circuit as simple as possible and to use only popular / cheap electronic parts. The device has been tested with very small coil (55mm diameter, about 30 turns of 0.5 … Read more

Microcontrollers and basic bit-level operations

Why it’s so important to know how it works? Well, if you’re making a software for microcontrollers you have to use it in many places in the code to for example manipulate table of processor registers. It also helps to make the program smaller, much faster and allows to perform neat tricks (this isn’t always … Read more

ESP32 – quick overview

The ESP32 is a low cost, low power microcontroller with integrated 2.4 GHz Wi-Fi (up to 150Mbps) and dual-mode Bluetooth (classic and BLE), which employs a dual-core Tensilica Xtensa LX6 microprocessor. ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company, and is manufactured by TSMC using their 40 nm process. It is … Read more

Microcontrollers and pull-up / pull-down resistors

A pull-up resistor is a resistor connected between a signal conductor (GPIO) and a positive power supply voltage while a pull-down resistor is a resistor connected between a signal conductor and a ground. They are used on inputs to prevent floating lines, rapidly switching between high and low and a middle “undefined” region. Outputs normally do … Read more

What is Serial Peripheral Interface (SPI) ?

Serial peripheral interface (SPI) is a hardware/software communication protocol originally developed by Motorola and widely used by others in the industry. SPI is quite straightforward – it defines how to communicate in easy way between 2 digital devices – i.e. between AVR and devices, like other AVRs, external EEPROMs, DACs, ADCs, etc. SPI is a single-master … Read more

AVR MCU Architecture

The AVR architecture is a huge topic in itself. I will just provide a general picture of how the AVR microcontroller works. The AVR uses a Harvard architecture thus it has separate memories and buses for program and data. Instructions in the program memory are executed with a single level pipelining. While one instruction is … Read more

What is an AVR Microcontroller ?

The AVR is a modified Harvard architecture 8-bit RISC single-chip microcontroller. The AVR was developed by Atmel in 1996 and was one of the first microcontroller families to use on-chip flash memory for program storage. The AVR microcontoller is like a small computer – includes a CPU, some flash program memory, some SRAM and some … Read more