Module 1/5 · Weeks 1–3 · 27 h

MCU architecture

UAT 204 Microcontrollers and Embedded Systems

About 80 minDraft, awaiting reviewLast updated 27 September 2026

Lesson

By the end of this module you will be able to

  1. Explain the parts of a microcontroller - CPU, memory, bus and peripherals
  2. Compare the microcontrollers in a Pixhawk 6X flight controller, a Pico 2 and an ESP32-S3
  3. Calculate ADC resolution and convert a digital reading back to voltage
  4. Design a voltage divider to measure battery voltage with an ADC

Prerequisites: UAT 103 (electrical and electronics) and UAT 104 (programming)

Why this matters

A single drone contains several small computers: the flight controller, every ESC, the GPS and even some smart batteries each have their own microcontroller (MCU). An MCU is a whole computer shrunk into one chip, CPU, memory and interface circuits together, designed to do specific jobs with guaranteed timing, low power and low cost, unlike general-purpose computers that can do many things but guarantee no timing.

The whole course uses one hypothetical case: building an add-on sensor module for a drone on a Raspberry Pi Pico 2 that reads sensors, measures voltage, drives a servo and sends data to the flight controller. The Python code of every module can be downloaded from /downloads/uat-204/.

Inside a microcontroller

A microcontroller chip outline. On the left, a Cortex-M CPU core, Flash and SRAM connect to a central bus. The bus connects to six peripheral groups: GPIO; timer and PWM; ADC; UART, I2C and SPI; CAN; and DMA with interrupts
Figure 1 Inside a microcontroller
  • The CPU core executes instructions; most MCUs in drone work use Arm Cortex-M cores
  • Flash stores the program and constants, and keeps them when powered off
  • SRAM holds variables while running, and loses them when powered off
  • The bus carries data between all parts
  • Peripherals are dedicated circuits on the chip, such as GPIO (digital inputs and outputs), timers, the ADC (analog-to-digital converter) and communication circuits, which work alongside the CPU

MCUs in drone work

The main processor (FMU), an STM32H753 Cortex-M7 at 480 MHz with 2 MB flash and 1 MB RAM, links both ways with the IO processor, an STM32F100 at 24 MHz. The main processor connects to the IMU, barometer and compass over SPI and I2C, to GPS and telemetry over UART, and to DroneCAN over CAN. The IO processor handles PWM outputs and RC input
Figure 2 The two processors in a Pixhawk 6X
BoardMCUStrengths
Pixhawk 6X (flight controller)STM32H753 Cortex-M7 at 480 MHz, 2 MB flash, 1 MB RAM, plus an STM32F100 IO processorOffloads outputs to a second processor
Raspberry Pi Pico 2 (lab)RP2350, dual Cortex-M33 (or RISC-V) at 150 MHz, 520 KB SRAMCheap, 12-bit ADC, 16 PWM channels
ESP32-S3Dual Xtensa LX7 at 240 MHz, 512 KB SRAMBuilt-in Wi-Fi and Bluetooth

All figures come from the PX4, Raspberry Pi and Espressif documentation. Flight controllers use faster MCUs with more memory because they must estimate state and control attitude hundreds of times a second.

The ADC: from voltage to numbers

An ADC (analog-to-digital converter) turns a voltage into an integer. An -bit ADC divides 0 to into steps, each called an LSB. The RP2350 has a 12-bit ADC, so 4,096 steps.

An ADC pin can take no more than the chip’s reference voltage (about 3.3 V), but a 6S battery reaches 25.2 V, so it must first be reduced with a voltage divider.

Example 1 Measuring a 6S battery with a 12-bit ADC

Resistors kΩ and kΩ, reference voltage 3.3 V.

vref, bits = 3.3, 12
lsb = vref / 2 ** bits
r1, r2 = 100_000, 10_000
ratio = r2 / (r1 + r2)
print(f"LSB = {lsb * 1000:.3f} mV at the pin = {lsb / ratio * 1000:.2f} mV of battery voltage")
for v_batt in (25.2, 22.2, 19.8):
    v_pin = v_batt * ratio
    code = round(v_pin / lsb)
    print(f"battery {v_batt:5.1f} V -> pin {v_pin:.3f} V -> code {code:4d} -> read back {code * lsb / ratio:.3f} V")
LSB = 0.806 mV at the pin = 8.86 mV of battery voltage
battery  25.2 V -> pin 2.291 V -> code 2844 -> read back 25.204 V
battery  22.2 V -> pin 2.018 V -> code 2505 -> read back 22.200 V
battery  19.8 V -> pin 1.800 V -> code 2234 -> read back 19.798 V

A full 25.2 V battery puts about 2.29 V on the pin, safely below 3.3 V. Each ADC step equals about 8.9 mV of battery voltage. Real accuracy also depends on resistor tolerance, noise and reference accuracy, so calibrate against a multimeter as in UAT 321.

Module lab

Lab: getting to know the Pico 2

  1. Read the Pico 2 pinout and identify GPIO pins, ADC pins, 3.3 V and ground.
  2. Install the programming tools (MicroPython or the C/C++ SDK, as the instructor directs) and write an LED blink program.
  3. Build the voltage divider on a breadboard, using an adjustable supply instead of a battery (no higher than the calculated safe value), and read the ADC at three voltages.
  4. Compare readings with the code in Example 1 and a multimeter, and find a calibration factor.
  5. Open the Pixhawk 6X page in the PX4 documentation and identify which processor each sensor and port connects to.

Common mistakes

Watch out

  • Applying more than 3.3 V to an ADC or GPIO pin, which may destroy the chip at once
  • Forgetting a common ground between the measured circuit and the MCU
  • Trusting ADC readings without calibration
  • Choosing an MCU by CPU speed alone without checking the peripherals needed
  • Assuming SRAM contents survive power-off

Summary

  • An MCU combines CPU, memory, bus and peripherals on one chip, doing specific jobs with guaranteed timing
  • The Pixhawk 6X uses an STM32H753 as its main processor and an STM32F100 as its IO processor
  • An -bit ADC divides the voltage range into steps
  • Measure high voltages through a voltage divider, and calibrate

Check your understanding

  1. What is the resolution of a 10-bit ADC with a 3.3 V reference, in mV?
  2. A divider with kΩ and kΩ has 16.8 V in. What is the pin voltage?
  3. A 12-bit ADC with a 3.3 V reference reads 2048. What is the pin voltage?
  4. Which loses its data at power-off, Flash or SRAM?
  5. Which MCU is the Pixhawk 6X main processor?
Answers
  1. mV
  2. V
  3. V
  4. SRAM
  5. STM32H753 (Cortex-M7 at 480 MHz)

Key formulas

ADC resolution
Voltage divider

Key references

  1. White, E. (2024). Making embedded systems: Design patterns for great software (2nd ed.). O'Reilly Media.
  2. PX4 Autopilot. Holybro Pixhawk 6X. PX4 user guide. link
  3. Raspberry Pi Ltd. Raspberry Pi Pico 2. link
  4. Raspberry Pi Ltd. RP2350 datasheet. link
  5. Espressif Systems. ESP32-S3. link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lab or field practice from worksheets with a safety checklist

Learning evidence: Checked worksheets and quiz results

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Sensors and embedded systems