Handbook sections
An embedded engineer's handbook: STM32, ESP32, circuits, C, RTOS, networking. Every section is checked by building and running the code. With a virtual lab, calculators and an Android app.
- I. Basics
- 1. The microcontroller as such
- 2. The STM32 portfolio and choosing a chip
- 2а. STM32 clones and fakes: how to tell them apart
- 2б. STM32U5 and TrustZone: how the new generation differs from the F4
- 2в. STM8: the eight-bit relative — what to take and what not
- 2г. Milandr K1986VE92: a domestic Cortex-M3 next to the STM32
- 2д. The STM32U585CIU6 in a 48-pin package: what remains of the U585 and what to put it in
- 2е. TrustZone in practice: SAU, GTZC, the call gateway and two projects on the STM32U585
- 2ж. BlackPill on the STM32F411: a Cortex-M4 with FPU at a BluePill price — the board, USB loading and three examples
- 3. The C language for embedded systems
- 3а. Bit operations
- 4. Toolchain
- 4а. Keil: the project and the structure of a program
- 4б. STM32CubeIDE: project, build, debugging and failure analysis
- 4в. Building without an environment: GCC, a Makefile, startup code and your own linker script
- 5. Three levels of abstraction: CMSIS, HAL and LL
- 5а. HAL in practice: three transfer modes, states, callbacks
- II. Core and system mechanisms
- 6. Clocking (RCC)
- 7. Interrupts and exceptions
- 7а. Exception entry from the inside: the stack frame, EXC_RETURN and the FPU
- 7б. Cortex-M assembly: Thumb-2 through the eyes of C
- 7в. Cortex-M assembly in practice: start-up code, atomics, DSP and task switching
- 8. Input/output ports (GPIO)
- 9. Direct memory access (DMA)
- 9а. GPDMA on STM32U5: linked lists, triggers and ring reception without interrupts
- 10. Power and power saving
- 10а. Low power on L4 and U5: Stop 2, Stop 3, Standby with SRAM2, Shutdown
- 10б. LPBAM on STM32U5: peripherals work in Stop 2 while the core sleeps
- 11. Memory, linking, loading
- 11а. MPU: protecting memory from your own mistakes
- 11б. Cache, TCM and memory domains on F7 and H7
- 11в. Read protection on the F1: why level 1 does not save the firmware
- 12. Service blocks: watchdog timers, CRC, RTC
- 12а. The new-style RTC: subseconds, calibration, wakeup, TAMP
- 12б. Firmware self-test: RAM, Flash, clocks and the core during operation
- III. Peripherals
- 13. Timers (TIM)
- 13а. Servo: 50 Hz PWM, 1–2 ms pulse, angle, smooth motion and power
- 13б. Buzzer: active and passive, notes on a timer, a non-blocking melody
- 13в. 16-channel PWM PCA9685 over I2C: servos and LEDs without the microcontroller's timers
- 14. Analog-to-digital converter (ADC)
- 14а. ADC errors: offset, gain, nonlinearity and noise — what can be calibrated and what cannot
- 15. Digital-to-analog converter (DAC)
- 15а. The new-style ADC on the G4: differential input, oversampling to 16 bits, two calibrations
- 15б. The external ADS1115 ADC over I2C: 16 bits, the PGA amplifier, the multiplexer, conversion modes and the ALERT/RDY pin
- 15в. The external MCP4725 DAC over I2C: 12 bits, fast write and EEPROM, the supply as the reference, signal generation
- 16. UART / USART
- 16а. RS-485: the line, terminators, bias and transmit direction
- 16б. Lossless UART reception: DMA into a ring, IDLE and the half buffer
- 16в. Bluetooth module HC-05/HC-06: transparent UART, AT mode, pairing and a protocol over the link
- 16г. MP3 module DFPlayer Mini over UART: command frame, checksum, track queue, volume and module replies
- 17. The I²C bus
- 17а. The microcontroller as a slave device: I²C and SPI
- 18. The SPI bus
- 18а. Audio over I2S: the frame, the formats and an exact sample rate
- 18б. SAI and DFSDM: multichannel audio and digital microphones
- 18в. A synthesizer on STM32: a look at the Mutable Instruments modules — codec, sample block and real-time DSP
- 18г. RFID reader RC522: MFRC522 over SPI, card search, UID, anticollision, reading MIFARE Classic blocks
- 18д. NFC module PN532: frames over I2C/SPI/UART, ACK, reading the UID and NTAG2xx, emulation and the difference from RC522
- 18е. DDS generator AD9833 over SPI: phase accumulator, frequency and phase, sine/triangle/square, sweep and FSK
- 19. The CAN bus
- 19а. CAN FD on FDCAN: 64 bytes, two bit rates, message RAM
- 19б. CANopen: object dictionary, NMT, PDO and SDO
- 19в. ISO-TP (ISO 15765-2): long messages over CAN
- 19г. OBD-II: car diagnostics over CAN — modes, PIDs and trouble codes
- 19д. UDS (ISO 14229): sessions, reading data, trouble codes and flashing through diagnostics
- 19е. DBC files: how to decode someone else's CAN bus
- 19ж. USB-CAN adapter and SocketCAN: candleLight, can-utils and a car diagnostics test bench
- 19з. rusEFI: an open engine control unit on STM32 — sensors, CAN and diagnostics
- 19и. J1939: the CAN of trucks and special machinery — PGN, SPN and DM1 diagnostics
- 19к. K-line: diagnostics of older cars via ISO 9141 and KWP2000 over UART
- 19л. LIN: the cheap body-electronics bus — break, sync, PID and the frame schedule
- 19м. rusEFI from the inside: spark and injection by crank angle — dwell, advance and an event queue on a single timer
- 19н. MCP2515 CAN controller over SPI: when the microcontroller has no bxCAN, bit timing at 8 MHz, buffers, filters and interrupts
- 20. USB
- 20а. USB OTG and host; 48 MHz without a crystal
- 20б. USB-C and UCPD: power and roles over the cable
- 20в. USB HID in practice: the report descriptor and a composite device
- 20г. A keyboard on STM32: dissecting QMK — matrix, debounce, layers and USB HID
- 20д. Your own USB device without a driver: descriptors byte by byte, MS OS 2.0 and WinUSB
- 21. SWO and ITM debug output
- 21а. RTT: output and input through the debugger without SWO or UART
- 22. External circuitry and indication
- 22а. A graphical interface on a display: frame buffer, LTDC, DMA2D and touch
- 22б. A camera over DCMI: a frame into memory through DMA
- 22в. Segment LCD: the glass, multiplexing and the LCD controller
- 22г. Addressable LEDs: WS2812B, SK6812 RGBW and SK6812WWA — protocol, timing, SPI, timer with DMA, power and levels
- 22д. Character LCD LCD1602 on the HD44780: 4 bits, initialization, command timing, CGRAM, I²C adapter
- 22е. LED display drivers TM1637 and MAX7219: a custom two-wire protocol, SPI words, brightness, a cascade of 8×8 matrices
- 22ж. IR remote and the NEC protocol: VS1838/TSOP receiver, timer capture, interrupt-driven decoder, repeat and noise
- 22з. Color TFT display ST7735 over SPI: initialization, address window, RGB565, font, DMA and partial update
- 22и. Port expander MCP23017 over I2C: 16 lines, interrupt-on-change, keypad and bounce
- 22к. Resistive touchscreen and the XPT2046 controller over SPI: X/Y measurement, pressure, three-point calibration and bounce filtering
- 43. Hardware cryptography: CRC, RNG, HASH, CRYP
- 43а. Where TLS gets its randomness: the hardware RNG, your own entropy source and quality checks
- 43б. The ATECC608 secure element: a key that cannot be read from the firmware
- 44. Analog blocks inside the chip: OPAMP and COMP
- 45. Touch input: TSC
- 46. Special-purpose timers: HRTIM and LPTIM
- 46а. CORDIC: sine, cosine and phase in a few clock cycles
- 46б. FMAC: the G4 filter accelerator — FIR and IIR without the processor
- IV. FreeRTOS
- 23. Why you need an operating system
- 23а. A device without an OS: state machines, an event queue, non-blocking drivers
- 24. How FreeRTOS is organized
- 25. Memory management
- 26. Tasks
- 27. Queues
- 28. Interrupts in an RTOS
- 29. Software timers
- 30. Synchronization and thread safety
- 31. Events and notifications
- 32. Stream and message buffers
- 32а. Active objects: an event-driven device architecture — a task, its own queue and a state machine
- 33. Configuration and power saving
- 33а. A watchdog for several tasks: who has hung and how to notice it
- 33б. FreeRTOS tracing: trace macros and a task timeline
- 34. FreeRTOS macros and functions: reference
- 34а. Zephyr: a different operating system — an overview for those who know FreeRTOS
- V. Debugging and quality
- 35. Debugging
- 35а. Semihosting: output and files through the debugger
- 35б. Flashing and debugging from the command line: OpenOCD, GDB, CubeProgrammer CLI
- 35в. A failure in the field: a state snapshot that survives a reset, and analysis after reboot
- 35г. A log on the device: levels, a ring buffer and binary records instead of printf
- 35д. How the debugger controls the core: SWD, the DP and AP ports, halting the core and FPB breakpoints
- 36. Typical problems: symptom → cause → fix
- 36а. Instruments on the bench: multimeter, oscilloscope, logic analyzer
- 36б. Run-time self-test: core, RAM, flash, clock
- 36в. Noise-robust firmware: traps in free Flash, empty vectors, program flow monitoring
- 36г. Oscilloscope, part 1: channel input, time base, memory and acquisition modes
- 36д. Oscilloscope, part 2: triggering — every kind of trigger and when to use which
- 36е. Oscilloscope, part 3: cursors, automatic measurements, math and FFT
- 36ж. Oscilloscope, part 4: bus decoding, masks, segmented memory, saving and SCPI control
- 36з. Galvanic isolation in measurements: oscilloscope ground, isolated channels, differential probe
- 36и. Your own differential probe: isolated amplifier, isolated power, divider and verification
- 36к. Signal generators: function, DDS, arbitrary waveform and a generator on STM32
- 36л. Analyzers: logic, spectrum, network (NanoVNA) and bus
- 36м. Higher-end RIGOL oscilloscopes: DHO1000 and DHO4000 — what they add and how remote control differs
- 36н. Oscilloscope and generator at work: a practicum on the DHO900 and DG900 Pro
- VI. Practice
- 37. IoT applications
- 37а. What TLS costs on a microcontroller: Mbed TLS in flash and RAM
- 38. Consolidated project catalog
- 38а. Interview questions: a hundred questions on the handbook with short answers and a section reference
- 41. External memory: SPI Flash, NAND, SD
- 41а. SD card over SDIO: four data lines, commands, DMA and FatFS
- 41б. FSMC and FMC: 8080 display, external SRAM and SDRAM
- 41в. Quad-SPI: external flash as memory and code from it
- 42. The FatFS file system
- 42а. LittleFS on SPI NOR: a file system that survives power loss
- 47. Control: feedback, P and PID controllers
- 48. A custom bootloader and firmware updates
- 48а. Firmware signing: the bootloader checks who built it
- 48б. MCUboot on STM32: two slots, image swap and rollback
- 48в. Delta update: sending only the changes in the firmware
- 48г. Encrypting the firmware image: the key, the AES mode and where the key lives in the device
- 48д. The ST factory bootloader in system memory: entry via BOOT0 and from firmware, the USART protocol, your own flashing utility
- VII. Documentation and its language
- 39. How to read ST documentation
- 39а. Official documents: what to get and where
- 39б. Errata in practice: how to read the silicon errata list and work around the bugs
- 39в. From a third-party chip's datasheet to a driver: HTS221 from the first page to testing without a board
- VIII. Electronics around the microcontroller
- 49. Voltage, current, power: Ohm's law and first calculations
- 50. I-V curves, voltage divider, RC circuits
- 50а. Circuits in frequency: magnitude response, phase response and the Bode plot
- 51. Semiconductors: diodes, Zener diodes, bipolar transistors
- 52. Switching loads: switches, relays, MOSFETs, drivers
- 53. Power supplies
- 54. Galvanic isolation
- 55. Linear regulators
- 56. Operational amplifiers
- 57. PWM in power electronics
- 57а. Motors: brushed, stepper, brushless
- 57б. Motor current: shunt, amplifier, sampling at the right moment of the PWM
- 57в. VESC and OpenInverter: power electronics controlled over CAN
- 57г. Klipper: STM32 as the executor of a 3D printer — steps on a schedule from the host
- 57д. FOC by hand: SimpleFOC and ODrive — field oriented control of a brushless motor
- 57е. Stepper motor winding current: the PWM chopper and decay modes
- 57ж. Microstepping without a driver: a gauge stepper motor driven straight from a timer
- 57з. Brushed motor driver: L298N and TB6612FNG — H-bridge, PWM on a timer, braking, encoder and speed PID
- 57и. AS5600 magnetic encoder: angle over I2C and PWM, zero position, turn counting and speed
- 58. Switching converters
- 59. Digital logic: gates and the laws of Boolean algebra
- 60. Multiplexers, decoders, combinational circuits
- 61. Minimal circuit around the microcontroller: start-up conditions
- 62. Pin protection
- IX. The C language: from basics to advanced
- 63. How text becomes a program; number systems
- 64. Data types
- 65. Branches and loops
- 66. Functions, scope, recursion
- 67. Pointers and pointer arithmetic
- 68. Arrays and strings
- 69. Floating-point numbers
- 70. Structures and files
- 71. Multi-module programs, the preprocessor, command-line arguments
- 72. Debugging and dynamic data structures
- 73. Measuring time and performance
- 74. C libraries
- 75. Code optimization
- 75а. A profiler on the chip itself: sampling the program counter by timer and through the DWT
- 76. Algorithms
- 77. Compilation and compilers
- 78. Sockets and a web server in C
- X. Design, networks and IoT
- 79. How a device is born: the stages of development
- 80. Arduino prototype: the board, the IDE, the first sketch
- 81. Sensors on a prototype and fighting noise
- 81а. Digital filters: FIR, IIR and CMSIS-DSP
- 81б. The Goertzel algorithm: finding a tone without an FFT
- 82. Indication on a prototype: PWM, RGB, shift registers
- 83. I²C and SPI on a prototype: a sensor and a display
- 84. Interrupts and timing on a prototype
- 84а. From sketch to registers: one device on four levels
- 85. TinyML: machine learning on a microcontroller
- 86. Network types and core technologies
- 87. Virtualization, clouds, containers
- 88. Distributed systems and APIs
- 89. Network protocols and mesh networks
- 90. IoT solution architecture
- 91. IoT platforms
- 92. Radio site survey and coverage map
- 93. LoRa: the radio, the SX1276 module, range
- 93а. nRF24L01: a 2.4 GHz radio over SPI — addresses, channels, Enhanced ShockBurst, acknowledgements and retransmits
- 94. LoRaWAN: network, keys, classes
- 94а. ST25DV NFC tag: the phone and the microcontroller share one memory
- 94б. Flipper Zero inside: STM32WB55, FreeRTOS and 433 MHz radio, NFC, RFID and IR in one firmware
- XI. Sensors: connection, circuits, drivers
- 95. How to connect sensors: power, pull-ups, levels, wires
- 95а. Level shifters: a transistor with pull-ups, TXB and TXS — why the module fails with I²C and a long wire
- 96. Temperature: NTC thermistor and DS18B20
- 97. Humidity: DHT22, SHT31 and AHT20
- 98. Pressure and altitude: BMP280 and BME280
- 99. Motion: MPU-6050 and ADXL345
- 99а. A flight controller on STM32: inside Betaflight — 8 kHz gyro, filters, PID and DShot
- 99б. IMU orientation: the quaternion, the Madgwick filter and magnetometer calibration
- 99в. NEO-6M GPS receiver: NMEA over UART, sentence parsing, checksum, time and coordinates, PPS
- 99г. QMC5883L/HMC5883L magnetometer compass over I2C: heading, hard/soft iron calibration, tilt and magnetic declination
- 100. Distance and presence: HC-SR04 and HC-SR501
- 100а. Human presence with a 24 GHz radar: HLK-LD2420 — range by gates, the UART protocol and threshold tuning
- 100б. VL53L0X laser rangefinder: time of flight over I2C, accuracy and speed modes, several sensors on one bus
- 101. Current and voltage: INA219 and ACS712
- 101а. Current and power monitor INA226: 16 bits, calibration register, averaging, threshold alert and energy counting
- 102. Weight: load cell and HX711
- 103. Light and gas: photoresistor, BH1750, MQ
- 103а. MAX30102 pulse oximeter: photoplethysmogram over I2C, FIFO, pulse extraction and SpO₂ estimation — and why it is not a medical device
- 103б. TCS34725 colour sensor over I2C: RGBC channels, integration time and gain, white balance, colour temperature and illuminance
- 103в. PMS5003 dust sensor over UART: 32-byte frame, PM1.0/PM2.5/PM10, active and passive mode, sleep and the air quality index
- 104. Thermocouple: MAX31855 and MAX6675
- 104а. Soldering iron on STM32: inside IronOS — a thermocouple in the tip, PID and USB Power Delivery
- 104б. MLX90614 IR thermometer over SMBus: contactless object temperature, PEC, emissivity and field of view
- XII. Networks and DevOps for the engineer
- 105. The network from the bottom up: Ethernet, MAC, IP, subnets, ARP
- 106. TCP and UDP from the inside: handshake, windows, retransmissions, NAT
- 106а. Ethernet on the F407: RMII, PHY over MDIO and DMA descriptors
- 106б. A packet byte by byte: Ethernet, ARP, IPv4, ICMP, UDP and TCP as a microcontroller sees them
- 106в. lwIP on STM32: buffers, three APIs and memory
- 106г. GSM modem SIM800L over UART: AT commands, SMS, calls and TCP over GPRS — non-blocking response parsing
- 107. What happens when you type an address: DNS, DHCP, HTTP, TLS
- 108. Routing, VLAN, Wi-Fi and VPN
- 109. Git for the engineer: branches, history, firmware versions
- 110. CI/CD for firmware: build in a container, tests, artifacts
- 110а. Firmware under the pipeline's eye: a size delta on every change and assert without strings in the release build
- 110б. A board on the desk in the pipeline: pytest, the serial port and your own runner
- 111. Containers and infrastructure: Compose, images, reverse proxy
- 112. Observability: logs, metrics, alerts
- XIII. Other languages and their build tools
- 113. Ada and SPARK: Alire, GNAT for Cortex-M, proof
- 114. Rust: Cargo, no_std, cortex-m-rt, embedded-hal
- 115. Build managers for firmware: PlatformIO, west (Zephyr), CMake presets
- 115а. A CMake firmware project: from .ioc to VS Code
- 115б. The serial port from the computer side: bridges, drivers, terminals, latency
- 115в. Python next to the device: port, bytes, log, test script
- 115г. Exchange formats: TLV, protobuf (nanopb) and CBOR on a microcontroller
- XIV. Machine learning on a microcontroller
- 116. Typical approaches and algorithms: from a threshold to a small neural network
- 117. Data from the sensor: windows, features, CMSIS-DSP
- 118. Training a small model in a container
- 119. Quantization to int8: CMSIS-NN and TensorFlow Lite Micro
- 120. Anomaly detection: vibration and predictive maintenance
- 121. Classic versus ML: the Kalman filter and battery state of charge
- 121а. OpenMV: a machine-vision camera on STM32H7 — DCMI, MicroPython and object search
- 121б. Audio on a microcontroller: from a PDM microphone to MFCC and command recognition
- 121в. STM32N6 and a battery-powered camera with a neural network: YOLO on the Neural-ART NPU, low power, an outdoor device
- XV. C in depth
- 122. Integer types and conversions: promotion, sign, overflow
- 123. Undefined behavior: where it hides and how to catch it
- 124. volatile, const and atomicity: interrupts and C11
- 125. Declarations and function pointers: handler tables and callbacks
- 126. Data in memory: alignment, packing, bit fields, byte order
- 127. The preprocessor as a tool: X-macros, _Generic, static_assert
- 128. The C99–C23 standards: what changed for firmware
- 129. MISRA C and defensive programming
- 129а. Unit tests for firmware on the PC: faking the hardware, a small runner of your own and coverage
- 129б. Static analysis of firmware: the clang analyzer, gcc -fanalyzer and cppcheck in the pipeline
- XVI. The circuit board
- 130. A board for a microcontroller: principles
- 130а. How to read a schematic: symbols, nets, sheets
- 130б. Heat on the board: thermal resistance, copper area and vias under the package
- 131. KiCad: a board from a script and checks from the command line
- 132. DipTrace: schematic, board and plug-ins
- 132а. DipTrace: custom patterns and components
- 132б. DipTrace: layers, rules, routing and copper
- 132в. DipTrace: checks, panels and fabrication files
- 132г. DipTrace: high-speed nets, differential pairs, vias to copper pours
- 132д. DipTrace: schematic and board together — hierarchy, SPICE, BOM, 3D
- 133. Altium Designer: project, rules, output
- 134. Other programs and moving boards between them
- XVII. Systems programming in C
- 135. The process: startup, environment, memory, limits, termination
- 136. fork, exec, wait and signals
- 137. Communication between processes: pipes, sockets, queues, shared memory
- 138. A daemon and its log: setsid, syslog, lock file, backtrace, core
- 139. POSIX threads and synchronization: mutex, cond, rwlock, barrier, TLS
- 140. C11 threads, atomic operations and OpenMP
- 141. Non-blocking I/O: select, poll, epoll, event descriptors
- 142. Web services in C: HTTP, REST, CGI, FastCGI, sendfile
- 143. Static and dynamic libraries: .a, .so, soname, rpath, LD_PRELOAD, dlopen
- 144. x86-64 assembly through the eyes of C: registers, calling convention, gcc -S, inline asm, nasm
- 145. UNIX as a development environment: POSIX, getopt, make, CMake, Meson, diff, gdb, valgrind, strace
- 146. Object-oriented C: opaque pointers, function tables, inheritance, _Generic
- 146а. C++ on a microcontroller: what is free and what is expensive
- 147. The Linux kernel: building, a module, a character device, ioctl
- 148. Databases from C: SQLite, PostgreSQL (libpq), Redis (hiredis)
- 149. Graphics and games in C: SDL2, the game loop, OpenGL
- XVIII. ESP32: the second microcontroller
- 150. ESP32 as a platform: chip, module, memory, pins, boot
- 151. ESP-IDF and tools: idf.py, components, Kconfig, partitions, esptool, QEMU, Arduino
- 152. FreeRTOS on two cores: task pinning, spinlocks, tick, stack, esp_timer, watchdog
- 153. GPIO and PWM on ESP32: pins, electrical limits, strapping, the signal matrix, LEDC, MCPWM
- 154. ESP32 ADC and DAC: attenuation, calibration, ADC2 and Wi-Fi, continuous mode, DAC and cosine
- 155. Storage on ESP32: the partition table, NVS, SPIFFS, FAT with wear levelling
- 156. Networking on the ESP32: esp_netif and lwIP, DHCP, SNTP, syslog, HTTP REST, MQTT
- 157. Sleep and the low-power domain of the ESP32: power modes, RTC memory, wakeup, the ULP coprocessor
- 158. Bluetooth LE on the ESP32: advertising, a GATT server on NimBLE, characteristics and notifications
- 159. Over-the-network updates on ESP32: OTA partitions, the bootloader, confirmation and rollback
- 160. Long lines on the board and in wires: characteristic impedance, reflections, termination, the I²C edge
- 161. Power and loads around the ESP32: the regulator, Wi-Fi peaks, switches, relays and spikes
- XIX. The analog path: op-amps and related parts
- 162. Single-supply path to the ADC: y = m·x + b
- 163. Stability: phase margin, capacitive load, compensation
- 164. Real op-amp parameters: input bias current, supply noise, rail-to-rail
- 165. Noise: addition, resistors, the amplifier, 1/f and the ADC budget
- XX. Components and typical circuits around the MCU
- 166. Resistors in detail: TCR, pulse load, shunt, battery divider
- 167. Capacitors in detail: ceramic classes, ESR and ESL, decoupling, electrolytics
- 168. Inductors, chokes and ferrite beads: LC filter, resonance, saturation
- 169. Diodes in detail: drop versus current and temperature, Schottky leakage, recovery, power OR-ing
- 170. Bipolar transistor: principle, four modes, saturation, turn-off, current source
- 170а. Two-transistor circuits: compound pairs, mirror, differential pair, multivibrator, high-side switch and current limiter
- 171. Field-effect transistor: principle, regions, threshold and channel resistance, Miller plateau, body diode
- 172. Switches: high-side and low-side, gate driver, half bridge and dead time, soft start, analog switch
- 173. Power protection: reverse polarity, fuse, transient suppressor
- 173а. Power loss: how many milliseconds you have, PVD and BOR, what to save in time
- 173б. Li-ion on the board: charging, protection and how much is left
- 173в. An open BMS on STM32: a look at Libre Solar — cell measurement, balancing, protection and SOC
- 174. The crystal and the clock circuit: two frequencies, load capacitance, clock drift, start-up
- XXI. Analog building blocks
- 175. Comparators: delay, open-drain output, hysteresis, window comparator
- 176. Instrumentation amplifier: three op-amps, common-mode rejection, a path for input bias currents
- 176а. 4–20 mA current loop: receiving a sensor and driving a PLC input
- 176б. PT100/PT1000 resistance thermometer: ratiometry and 2-, 3- and 4-wire connection
- 177. Voltage references: divider, Zener diode, reference IC, drift and noise
- 178. Active filters: Sallen–Key, order, Q factor, the filter before the ADC
- 179. Oscillators and nonlinear circuits: relaxation oscillator, Wien bridge, precision rectifier, peak detector
- 180. The analog path around the ADC: sampling capacitor, buffer, multiplexer, driver
- 181. Analog layout: common ground, interference, shielding
- XXII. Software engineering
- 182. Firmware lifecycle and the cost of a defect
- 183. Schedules and people: the team, the late project, three-point estimates
- 184. Firmware testing: levels, coverage, mutations, sanitizers
- XXIII. The device's companion app: Dart and Flutter
- 185. Dart for the firmware engineer: bytes, numbers, frame parsing
- 186. Asynchrony: frame stream, timeouts, reconnection, isolate
- 187. A device screen in Flutter: widgets, state, commands, tests
- 188. The app's networking: HTTP, WebSocket and MQTT
- 189. BLE and USB serial: the link to the device, MTU, write queue, permissions
- 189а. Firmware update from a mobile app: from a button in Flutter to the STM32 bootloader
- 190. Telemetry and release: ring buffer, decimation, storage, build
- XXIV. Embedded Linux
- 191. Embedded Linux: when you need it and what the image is made of
- 192. Peripherals from a program: gpiochip, i2c-dev, spidev, sysfs
- 193. Device service: systemd, journal, permissions and watchdog
- 194. Link to the microcontroller: the port on the Linux side, COBS frames and CRC
- 195. A/B update: two slots, confirmation and rollback
- XXV. Mini-projects
- 196. Mini-project: a thermostat on the BluePill
- 197. Mini-project: a frequency counter on a timer
- 198. Mini-project: an RTC clock with an alarm and rate correction
- 198а. Mini-project: a battery-powered sensor — a year on one CR2032
- 198б. Mini-project: a USB data logger and a PC program
- 198в. Mini-project: a Modbus RTU I/O module
- 198г. Mini-project: gestures from an accelerometer
- 198д. Mini-project: a logic analyzer made from a BluePill
- 198е. Mini-project: a CAN sniffer on STM32 — the SLCAN protocol over USB CDC
- 198ж. UDP sensor: broadcast, network discovery and a custom protocol
- 198з. Web page and REST on STM32: lwIP httpd, SSI and CGI
- 198и. An MQTT client on the STM32: publish, subscribe and reconnect
- 198к. Mini-project: an oscilloscope on the board — ADC, DMA, edge trigger and a display on the PC
- 198л. Mini-project: everything on the F4-Discovery — accelerometer, audio DAC, microphone and USB
- 198м. Mini-project: weather station — sensors, log and display
- 198н. Mini-project: a GPS receiver — NMEA, PPS and precise time
- 198о. Mini-project: an IR remote — receiving and transmitting the NEC protocol
- 198п. Mini-project: MIDI — a UART input at 31250 and a synthesizer on the DAC
- 198р. Mini-project: an OBD-II scanner on STM32 — RPM, speed, temperature and trouble codes
- 198с. Mini-project: a CAN dashboard — RPM, speed and temperature from the car's bus
- 198т. Mini-project: a CAN bus logger to an SD card — recording a trip and analysing it on a computer
- 198у. Mini-project: your own unit on the CAN bus — sensor, DBC, UDS diagnostics and flashing over the bus
- 198ф. Mini-project: a USB flash drive on the B-U585I-IOT02A — the device serves its log as a disk
- 198х. Mini-project: the B-U585I-IOT02A board sensors — climate, motion and light
- 198ц. Mini-project: a log in the external Octo-SPI flash of the B-U585I-IOT02A
- 198ч. Mini-project: a USB host on the B-U585I-IOT02A — keyboard and flash drive
- 198ш. Mini-project: a USB COM port and a keyboard in one device on the B-U585I-IOT02A — a composite CDC + HID device
- 198щ. Mini-project: your own bootloader for a production device on the STM32F405 — sector layout, staging slot, updates over UART-Bluetooth and protection against power loss
- 198э. Mini-project: a temperature sensor over Bluetooth LE on the P-NUCLEO-WB55 — two cores, IPCC and a custom GATT service
- 0. About the handbook
- 0. Where to start and where to go
- 0а. Beginner's route: twenty sections in order
- 0б. Topic routes: CAN and automotive diagnostics
- 0в. Topic routes: from prototype to product
- 0г. Topic routes: a device on an RTOS — architecture and observability
- XXVI. From prototype to product
- 199. Board assembly at the factory: BOM, placement file and Gerber
- 200. First power-on of a new board
- 201. Production test and programming on the line
- 201а. Firmware release: version, metadata and one file for production
- 202. Calibration on the production line
- 203. Product EMC: interference, immunity and workshop testing
- 204. Reliability: margins, aging and in-house testing
- 204а. Device enclosure: from board to enclosure, tools, checks before printing
- 205. Product documentation: the set, designations, revisions
- 205а. ESKD documents for a device: codes, the E3 schematic, the PE3 list of elements from KiCad
- 205б. Open-source licenses and SBOM: what you may put into firmware
- 206. Certification: conformity assessment and radio modules
- 206а. EAEU certification step by step: regulations, declaration or certificate, scheme, EAC
- 207. The assembly workbench: static, SMD soldering, cleaning
- 208. A device powered from 230 V mains: safety and power supply
- 208а. A device powered from 24 V: industrial supply, input protection and digital inputs
- 208б. A 230 V load from a microcontroller: relay, triac, solid-state relay
- Appendices
- A. STM32F1 register maps
- A2. STM32F4 register maps
- A3. STM32F0 register maps
- A4. STM32F2 register maps
- A5. STM32F3 register maps
- A6. STM32F7 register maps
- A7. STM32H7 register maps
- A8. STM32H5 register maps
- A9. STM32G0 register maps
- A10. STM32G4 register maps
- A11. STM32C0 register maps
- A12. STM32L0 register maps
- A13. STM32L1 register maps
- A14. STM32L4 register maps
- A15. STM32L5 register maps
- A16. STM32U5 register maps
- A17. STM32WB register maps
- A18. STM32WL register maps
- B. CMSIS cheat sheet
- C. HAL API cheat sheet
- D. FreeRTOS API cheat sheet
- E. Board pinouts
- F. Abbreviations
- G. Index of registers and functions
- H. Peripheral × series × section: what exists where and where to read about it