# Protocols&Interfaces

Electronics is about voltage and stuffs but as humans we use it for connect devices and devices connected need ways to communicate.

## PWM

The acronym means Pulse Width Modulation and it's the simplest way to digitally encode a signal using a single wire; it's defined by the duty cycle, i.e. the percentage of the cycle that the signal is on (0% is always off, 100% is always on) and its switching frequency, that identify how many seconds each raising edge appears.

Its fourier transformed form is given by this coefficients ($p$ is the duty cycle $0\leq p\leq 1$)

## UART and Serial

The simplest of protocols without needing a clock line, usually it's exposed as a 4 pins header but it's also possible to be exposed via already used IO port (like headphone socket or USB port via USB port multimedia switch).

• http://wiki.openwrt.org/doc/hardware/port.serial
• http://www.devttys0.com/2012/11/reverse-engineering-serial-ports/
• Chapter about design of a USART interface

## I2C

It uses only two wires, and allows to connect up to 1008 slave devices.

## SPI

It's a protocol with a clock line and a differentiation between devices that can be master (that provides clock) or slave. Although may there be only one master there is a signal (SS) that indicates which one of the (possible) multiple slaves must respond.

It has the disadvantage that the communication must be well defined in advance since the master must know how many clock cycle need to listen from the slaves.

### SD Card

For example an SD Card use this protocol (see a link in the Bus Pirate page) how you can read here and here.

The pin CD stand for card detection: when is low the card is inserted into its socket.

## JTAG

It's a protocol used to debug hardware and uses the following pins that constitute the TAP, the Test Access Port:

• TMS: Test Mode Select. This pin is used to cycle through the TAP-state machine.
• TCK: Test Clock.
• TDI: Test Data In. Serial input data to be shifted in to the Instruction Register or Data Register.
• TDO: Test Data Out. Serial output data from Instruction Register or Data Register.

There are also some optional pins:

• TRST: TAP reset, optional because is always possible to out the state machine to a start state
• SRST: system reset, allows to reset the system

Usually on reference is indicated also the VTRef pin that indicates what is the voltage reference for the signals.

## USB

This is a well known protocol, used everywhere in electronics devices, the acronym means Universal Serial Bus.

This protocol can work at three defined speeds

Name Speed
Low 1.5Mbit/s
Full 12Mbit/s
High 480Mbit/s

The architecture of this protocol is tiered star topology, there can be no communication directly between USB devices.

## Dialup

Below the image of the handshake, for more explanation, refer to this post