Independent learning for embedded-systems engineersHardware · Firmware · Software
TEA-104CORE EMBEDDED SYSTEMS TOPICFOUNDATION

Communications interfaces and protocols

Turn electrical connections into dependable contracts: select the right interface, define meaning and timing, and design explicitly for corrupted, delayed, duplicated and missing data.

After this module, you should be able to:

  • Separate physical, data-link and application concerns
  • Select an interface from system constraints
  • Specify a testable protocol contract
  • Design and verify failure behaviour
01 / SYSTEM VIEW

An interface is a boundary; a protocol is an agreement.

A connector and peripheral do not define communication. Dependable exchange needs compatible electrical behaviour, framing, message meaning, timing, ownership and failure responses at both ends.

Layering helps engineers reason about faults. A valid electrical waveform may contain an invalid frame; a valid frame may contain a command that is stale, unsafe in the current state or incompatible with the receiver’s version.

PHYSICALCan bits cross the boundary?Levels, topology, termination, isolation, shielding and connectors
TRANSFERCan frames be exchanged?Arbitration, addressing, framing, integrity, acknowledgement and flow control
APPLICATIONDo both ends agree?Commands, units, states, timing, validity, permissions and versions
Transport reliability is not system safety.A checksum can show that received bits match transmitted bits. It cannot show that the value is fresh, plausible, authorised or appropriate for the current system state.
02 / SELECTION

Select from constraints, not familiarity.

InterfaceUseful characteristicsQuestions and limitations
UART / serialSimple point-to-point link; easy to observe and bring up.Define framing, level translation, flow control and recovery from lost byte alignment.
I²CLow pin count and addressed peripherals on one board.Consider pull-ups, capacitance, clock stretching, stuck-bus recovery and address conflicts.
SPIHigh throughput, low protocol overhead and deterministic local transfer.Chip-select scaling, no standard message semantics and device-specific timing.
CANRobust shared bus, arbitration and strong frame-level error handling.Bus loading, message priorities, physical topology and the selected higher-layer protocol.
USBStandard host/device ecosystem, power options and defined device classes.Host dependency, enumeration, cable removal, class behaviour and update compatibility.
Ethernet / IPScalable networking and access to mature transport protocols.Variable latency, configuration, congestion, security and loss of network services.
WirelessNo cable and support for mobile or distributed products.Interference, coexistence, range, pairing, credentials, power and regulatory constraints.

Selection criteria should include distance, data rate, maximum latency, topology, environment, EMC, isolation, power, update needs, security, component availability, diagnostics and the consequences of communication loss.

03 / CONTRACT

Specify what each endpoint can depend upon.

  1. Define ownership. State who initiates, who may command, who publishes state and who decides that a link has failed.
  2. Define messages. Give every field a type, byte order, scale, unit, valid range and reserved-value rule.
  3. Define framing and integrity. Specify boundaries, length, sequence information, error detection and acknowledgement.
  4. Define timing. Include rates, deadlines, timeouts, retry limits, freshness and behaviour during overload.
  5. Define states. Cover start-up, discovery, synchronisation, normal exchange, degraded operation, reconnection and shutdown.
  6. Define compatibility. State how versions are identified, negotiated, rejected and updated.
  7. Define trust. Address authentication, authorisation, confidentiality and replay resistance where the threat model requires them.

Worked example: host computer to motor controller

A host sends cycle commands to an MCU over USB virtual serial. A safer contract separates command acceptance from command completion.

Framed command + sequenceSyntax and state checkAccepted / rejectedControlled executionCompletion + resultHeartbeat monitored

The controller rejects duplicates and commands that are invalid in its current state. If the heartbeat expires, it completes only the current bounded safe action, removes drive energy and reports the interruption after reconnection. Retries are bounded so a communications fault cannot create an endless command loop.

04 / EVIDENCE

Verify both conformance and resilience.

Interface specification

Physical details, message definitions, timing, states, error handling, versions and security properties.

Budget analysis

Bandwidth, bus loading, latency, buffers, retry traffic and worst-case utilisation.

Compatibility record

Supported endpoint combinations, negotiation rules and regression results.

Fault-injection results

Corruption, truncation, delay, duplication, reordering, disconnection and reconnection.

Protocol traces

Time-correlated captures that show actual messages, states and response times.

Security verification

Unauthorised commands, malformed input, replay, downgrade and resource-exhaustion tests.

Common failure patterns

Happy-path protocol

The message list is defined, but partial frames, restarts and missing responses are not.

Unbounded retry

Recovery traffic increases congestion or repeats an unsafe physical action.

Hidden units and scaling

Endpoints interpret the same integer differently, often without an obvious communication error.

Version by assumption

Independently updated endpoints connect without an explicit compatibility decision.

05 / REFERENCES

Further learning

KEY TAKEAWAY

Specify the failure semantics, not only the message format.

A dependable interface states what is exchanged, when it is valid, who owns each decision and what both endpoints do when communication fails.