Definition
A system on chip (SoC) is a single chip that holds the main parts of an electronic system: at least one processor core together with memory and peripherals. Peripherals are the blocks that do the other work, such as a radio, timers and communication interfaces. Each peripheral follows its own hardware rules and can work while the processor does something else. The term overlaps with microcontroller §6.1 (MCU, microcontroller unit): both name a processor, memory and peripherals on one chip, and the same chip is often called by either word.
The idea
A wireless sensor must answer a radio packet 150 millionths of a second after the packet ends, while its program is busy formatting a log message. One processor that runs one sequence of instructions cannot be in two places. But the processor is only one block of the chip. The radio, the timers and the other peripherals are separate circuits with their own state. The firmware, the chip’s program, sets them up in advance. They then act on their own clocks and report back.
A kitchen is a fair picture. The cook, who stands for the processor, puts a dish in the oven, sets the timer and turns to other work. The oven keeps heating without the cook, and a bell rings when the time is up. The bell stands for an interrupt §6.11: a signal that makes the processor pause and deal with an event. The picture stops in one respect. The blocks of a chip share wiring, clocks, power and memory, and a working peripheral may be using a piece of memory that the processor must leave alone until the work is done.
How it works
An SoC consists of these blocks.
Processor core: executes the firmware.
Memories: flash memory §6.6 for the program, RAM for working data.
Peripherals: radio, timers, serial interfaces, converters. Each has registers, which the firmware reads and writes like memory locations to configure and start the peripheral.
Bus: the wiring that carries reads and writes between core, memory and peripherals.
Clock and power control: produce the timing signals and switch blocks on and off.
A peripheral does a piece of work in these steps.
The firmware writes the settings into the registers of the peripheral, for example the address of a buffer, a region of RAM for the data.
The firmware starts the peripheral, or sets a hardware timer that will start it at an exact time.
The peripheral does the work without the processor. It may read or write the buffer directly, which is called direct memory access §4.36 (DMA).
When the work is done, the peripheral raises an event. The event can request an interrupt. On some chips it can also start another peripheral directly, through wiring inside the chip.
The processor pauses what it was doing, runs the interrupt service routine §6.12 (ISR) for that event and collects the result.
Between step 2 and step 5 the processor runs other code or sleeps.
Radio timing for Bluetooth Low Energy (BLE) §7.1, a radio standard for low-power devices, works this way. The software of a BLE device has two parts (see BLE Controller and Host §7.4): a Host, which runs the protocols that an application uses, and a Controller. The Controller contains the Link Layer §7.6, the software that decides at which instant each packet is sent or received. In the Zephyr RTOS §6.33 (real-time operating system), for example, the Link Layer runs in ISRs and programs hardware timers and the radio. On chips from Nordic Semiconductor, Zephyr’s Controller keeps the radio, a low-power counter and one or two timers for itself.
Worked example
Application code runs in threads, sequences of instructions that take turns on the processor. A BLE device that receives a packet in a connection must start its reply 150 microseconds after the packet ends. The Bluetooth specification sets this default and calls the gap the inter frame space. Each gap may differ from the average gap by at most 2 microseconds.
Take a processor clocked at 64 megahertz, as in the nRF52840 §6.4 chip from Nordic Semiconductor. That is 64 million clock cycles per second, or 64 per microsecond. The 150 microseconds are cycles. The allowed error of 2 microseconds is cycles. A thread that other work keeps waiting for 1 millisecond has lost cycles, more than six times the whole gap.
The radio of the nRF52840 has a register named TIFS that holds the gap in microseconds. A Link Layer that uses this register prepares the reply packet in RAM, writes 150 into TIFS and switches on the radio’s automatic change-over before the incoming packet ends. When the last bit has arrived, the radio changes by itself from receiving to sending and starts the reply after the programmed gap. No instruction has to run at that instant.
Stated precisely
The state of an SoC at one instant is the state of the processor, together with the state of every peripheral and the content of memory. The firmware directly controls only the processor’s part. Each peripheral changes its state by the rules in the chip’s specification, on its own clock. Two consequences follow.
A memory location or a register can change while no instruction of the firmware writes to it, if a peripheral was set up to write there.
An action that a peripheral or a hardware timer was programmed to perform happens at the programmed time, whichever thread is running, as long as that block keeps its clock and its power.
For radio timing, the hardware timer and the radio fix the instant of a transmission. The Link Layer decides what is sent. Where it runs in ISRs, as in Zephyr, thread priorities play no part. Two assumptions remain: the code of the Link Layer must be allowed to run in time, and the blocks involved must keep their clock.
Limits and common mistakes
Independent of threads does not mean independent of all software. ISRs run on the same processor. Firmware that keeps interrupts disabled for too long delays the ISRs of the Link Layer, and the radio can then miss its schedule.
The name of the processor core does not describe the SoC. Two chips with the same core can have different radios, memories and clocks; the reference is the specification of the SoC, not the manual of the core.
A buffer handed to a peripheral belongs to the peripheral until the peripheral reports completion. Reusing the buffer earlier corrupts the transfer, although no thread appears to use the buffer.
Halting the processor in a debugger does not halt every peripheral. The watchdog timer §6.16 of the nRF52840, which resets the chip unless the firmware restarts it in time, can be set to keep counting while the processor is halted.
Questions answered
Which subsystem handles radio timing independently of application threads?
The Controller, the lower part of the radio protocol software, handles radio timing, together with the radio hardware that it drives; application threads take no part. In a chip for Bluetooth Low Energy (BLE), three things handle radio timing: the radio peripheral, hardware timers that start and stop the radio at exact instants, and the Link Layer, the Controller software that programs both; in the Zephyr operating system the Link Layer runs in interrupt service routines (ISRs), which hardware events start. Application threads, and the Host protocols that serve them, only hand data to the Controller and receive data from it.
A BLE reply must by default start 150 microseconds after the received packet ends, with an error of at most 2 microseconds, and other threads can delay a thread for far longer than that. The hardware timers and the radio keep the instant; the Link Layer decides what is sent. The division of work between hardware and Controller software differs between chips and between protocol implementations. For a given device, name the radio hardware, the Controller software and the Host separately.
Related entries: BLE Controller and Host (§7.4), Direct memory access (DMA) (§4.36), Arm Cortex-M4 (§6.3), RTC versus cycle counter (§6.19), Microcontroller (MCU) (§6.1), nRF52840 (§6.4), Interrupt service routine (ISR) (§6.12), Link Layer (§7.6). Further reading: [93].