IAE Academy

FOR CORE AND IT JOBS · CHAPTER 1 OF 7

What a microcontroller is made of

This chapter explains what sits inside a microcontroller, how its memory and buses are organised, why small 8-bit and larger 32-bit parts both exist, what happens between reset and main(), and how clock and supply voltage set power. You need it to read a microcontroller datasheet.

Updated 30 Oct 2026

What you will be able to do

You will be able to name the blocks inside a microcontroller and say what each one is for. You will compare Harvard and von Neumann memory and count the bus time each needs. You will choose between an 8-bit and a 32-bit part from the job's data and speed. You will follow a part from reset to main() and estimate its power from clock and supply voltage.

Before you start

  1. Binary and hexadecimal numbers (written 0x1F), and powers of two

  2. Rounding up: the ceiling

  3. SI prefixes: p, n, µ, m, k, M

  4. Frequency and period,

  5. A capacitor's charge and stored energy ; power as energy per second

  6. A CPU fetching instructions from memory, registers as stored bits, and a bus as shared wires

  7. Reading a C variable declaration

One chip built for one job

An embedded system is a computer built into a product to do one job, such as running a washing cycle. A microprocessor is mainly the CPU: main memory and input/output sit on separate chips joined by buses on the circuit board. A microcontroller puts the CPU, program memory, data memory and input/output blocks on one chip. That saves cost, board area and power, which is what a single-job product wants.

  1. CPU core: fetches and executes instructions.

  2. Flash: non-volatile program memory, so it keeps its contents without power.

  3. RAM: volatile memory (it loses its contents without power) for variables and the stack, the area where a running function keeps its return address and local variables. A register called the stack pointer holds the address of the stack's top.

  4. EEPROM: non-volatile memory that can be rewritten byte by byte, slow and used for settings. Many parts have none.

  5. Clock: an oscillator giving the core its steps.

  6. Reset: circuits that put the core in a known state. Common sources are power-on, a supply dip, a watchdog timer (a timer that resets the part if the program stops restarting it in time) and a pin.

  7. Peripherals: timers, serial ports, analog-to-digital converters and input/output pins. They sit on internal buses and are read and written as registers at fixed addresses.

ADDRESSABLE BYTES

Holds when each address names one byte. : number of address bits; : number of bytes reachable. A 16-bit address reaches bytes, which is 64 KiB (1 KiB = 1024 bytes).

Memory buses and word size

In a von Neumann machine, instructions and data share one memory and one bus, so a fetch and a data access cannot happen in the same cycle. In a Harvard machine, program memory and data memory have separate buses, so they can. Many 8-bit parts also give them separate address spaces. Cortex-M is ARM's family of 32-bit microcontroller cores. It uses one address map, so a single load instruction can read flash or RAM. The larger Cortex-M cores have separate instruction and data buses; the smallest, such as M0 and M0+, have one.

BUS TIME FOR ONE INSTRUCTION

Model: the instruction is one fetch plus data accesses, every bus access takes the same time (s), and the Harvard machine overlaps the next fetch with this instruction's data accesses. The program bus is busy for while the data bus is busy for , so the longer of the two sets the time; with both machines take . : data accesses per instruction, a count. : bus time per instruction (s).

The word size is the width of the CPU's registers and arithmetic unit. It fixes how many bits one arithmetic instruction can handle.

RANGE OF AN UNSIGNED WORD

Holds for an unsigned integer in bits. gives 0 to 255 (0xFF); gives 0 to (0xFFFFFFFF).

PIECE ADDITIONS FOR A WIDE ADD

Holds for adding two -bit unsigned integers on an -bit core, one -bit piece at a time with the carry passed on. , : widths in bits. : number of piece additions, a count; rounds up.

WORKED EXAMPLE

Add two 32-bit unsigned integers held in RAM and store the sum. Compare an 8-bit core and a 32-bit core, both at 16 MHz, with every instruction taking one cycle. Ignore the instructions that set up addresses.

Solution
  1. 8-bit core: piece additions, because the core handles one byte at a time.

  2. Each piece needs: load a byte of the first number, load a byte of the second, add, store the byte. The lowest piece adds plainly; each higher piece adds the carry from the piece below. That is 4 instructions per piece, so cycles.

  3. Each cycle lasts ns, so the time is .

  4. 32-bit core: one register holds all 32 bits, so : 4 instructions, 4 cycles, .

Answer: 1 µs on the 8-bit core, 0.25 µs on the 32-bit core.

Property

Typical 8-bit part

Typical 32-bit Cortex-M part

Registers and arithmetic unit width

8 bits

32 bits

Core clock

a few MHz to a few tens of MHz

tens to hundreds of MHz

Flash

a few KiB to tens of KiB

tens of KiB to a few MiB

RAM

a few hundred bytes to a few KiB

a few KiB to hundreds of KiB

Supply voltage

often 1.8 V to 5.5 V

often 1.7 V to 3.6 V

Memory organisation

Usually Harvard, separate address spaces

One address map; separate instruction and data buses except on the smallest cores, such as M0 and M0+

The 8-bit part wins where the data fit in a byte and the work is light, such as reading a switch or an 8-bit sensor value. A wider word buys little there, and the smaller core costs less silicon. The 32-bit part wins where data are wide or the work is heavy, as the example shows. Choose by the job's data and speed, not by the larger number.

Reset, boot and the clock

Code that runs before main() prepares the memory your program assumes. It also sets the clock, which decides speed and power.

  1. Power rises. Power-on reset keeps the core idle until the supply passes a threshold and the clock is stable.

  2. The core reads the reset vector. On a typical Cortex-M part, the word at 0x00000000 is the initial stack pointer and the word at 0x00000004 is the address of the reset handler. On a typical 8-bit part, the first instruction at 0x0000 is usually a jump.

  3. Startup code runs. It sets the stack pointer on a part whose hardware does not load it at reset; a Cortex-M part already has it from step 2. It often sets the clock, copies the starting values of initialised variables from flash to RAM, and clears global and static variables that have no starting value to zero.

  4. Startup code calls main().

An internal RC oscillator needs no extra parts but is typically accurate only to within a few percent. A crystal is accurate to tens of parts per million. A phase-locked loop (PLL) multiplies a slow, accurate source up to the core clock. For low power, run at the lowest supply voltage the part allows at your clock, and stop the clock in a sleep mode between tasks. The formulas below show why.

DYNAMIC POWER OF THE CORE

Holds when switching dominates and leakage (current with no switching) is ignored. Each charge of to draws charge , energy , from the supply: half heats the charging path, and the half stored in is lost on discharge. : average fraction of charged and discharged per clock. : switched capacitance (F). : supply (V). : clock (Hz). in W.

ENERGY FOR A FIXED TASK

Holds when the task takes a fixed clock cycles, is unchanged and leakage is ignored. Time is (s). The clock frequency cancels: a slower clock cuts power but not the energy of the task. in J.

WORKED EXAMPLE

A core has pF and runs at V and MHz. A task takes cycles. Find and . Then find and at 5 MHz, and at 5 MHz with V.

Solution
  1. Power from : W mW.

  2. The task lasts ms, because each cycle lasts . So . Check: .

  3. At 5 MHz: halves to 4.5 mW because . The task now takes ms, so , unchanged.

  4. At 5 MHz and 1.5 V: mW, and . That is a quarter of 45 µJ because and .

Answer: 9 mW and 45 µJ; 4.5 mW and 45 µJ; 1.125 mW and 11.25 µJ. A lower clock alone saves power but not energy; a lower supply saves energy, where the part allows that voltage at that clock.

Check yourself

CHECK YOURSELF 1

A typical 32-bit Cortex-M part has just left power-on reset. What does the core read first?

  1. (A)

    The first instruction of main(), at address 0x00000000

  2. (B)

    The word at 0x00000000 as the initial stack pointer, then the word at 0x00000004 as the address of the reset handler

  3. (C)

    The word at 0x00000000 as the address of the reset handler, then the word at 0x00000004 as the initial stack pointer

  4. (D)

    The starting values of initialised variables, which it copies from flash to RAM

Answer and solution

Answer: (B)

  1. After reset the core reads the reset vector.

  2. On a typical Cortex-M part, the word at 0x00000000 is the initial stack pointer.

  3. The word at 0x00000004 is the address of the reset handler, which is startup code.

  4. main() is called last by startup code, and the copy of initial values is done by startup code, so A and D are wrong. C swaps the two words.

CHECK YOURSELF 2

One instruction needs 1 fetch and d = 2 data accesses. Every bus access takes t = 10 ns. Use the model and . By how many nanoseconds is the bus time per instruction shorter on the Harvard machine than on the von Neumann machine?

Answer and solution

Answer: (accepted range )

  1. Von Neumann: ns.

  2. Harvard: ns.

  3. Difference: ns.

CHECK YOURSELF 3One or more options are correct

A program has these two variables declared outside any function:

#include <stdint.h>

uint8_t count = 5;
uint8_t flag;

Which statements are true?

  1. (A)

    Flash keeps its contents when the power is off.

  2. (B)

    RAM keeps its contents when the power is off.

  3. (C)

    Startup code copies the value 5 for count from flash to RAM before main() runs.

  4. (D)

    Startup code clears the RAM byte of flag to 0 before main() runs.

Answer and solution

Answer: (A), (C), (D)

  1. Flash is non-volatile, so A is true.

  2. RAM is volatile and loses its contents without power, so B is false.

  3. The starting value 5 is stored in flash and copied to the RAM byte of count at start-up, so C is true.

  4. Global and static variables with no starting value are cleared to 0 by startup code, so D is true.

CHECK YOURSELF 4

A core has pF. A task takes clock cycles and the supply is V. Leakage is ignored. Find the energy of the task in µJ.

Answer and solution

Answer: (accepted range )

  1. For a fixed task, . The clock frequency cancels, so the clock is not needed.

  2. J.

  3. J .

Used in these GATE topics