asynchronous interface

68
Asynchronous interface Popular computer interfaces : Interfa ce Format Max Devices Cable Length Max Speed bps RS-232 Async Serial 2 50-100 ft 20K [115K *] Rs-485 Async Serial 32 4000 ft 10M IrDA Async Serial 2 6 ft 115K USB Async Serial 127 16 ft 12M

Upload: barclay-rice

Post on 01-Jan-2016

38 views

Category:

Documents


3 download

DESCRIPTION

Asynchronous interface. Popular computer interfaces :. Synchronous Interface. Popular computer interfaces :. About RS-485. When you need to transmit over long distances or at higher speeds than RS232 can handle, RS-485 is a solution. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Asynchronous interface

Asynchronous interface

Popular computer interfaces :

Interface Format Max Devices Cable Length Max Speed bps

RS-232 Async Serial 2 50-100 ft 20K [115K *]

Rs-485 Async Serial 32 4000 ft 10M

IrDA Async Serial 2 6 ft 115K

USB Async Serial 127 16 ft 12M

Page 2: Asynchronous interface

Synchronous Interface

Popular computer interfaces :

Interface Format Max Devices Cable Length Max Speed bps

Microwire Sync Serial 8 10 ft 2M

SPI Sync Serial 6 10 ft 2.1M

I2C Sync Serial 40 18 ft 400K

Firewire Sync Serial 64 15 ft 400M

IEEE-488 Sync Serial 15 60 ft 1M

Ethernet Sync Serial 1024 1600 ft 10M

Page 3: Asynchronous interface

About RS-485

When you need to transmit over long distances or at higher speeds than RS232 can handle, RS-485 is a solution.

Another advantage is that the RS-485 link is not limited to just two devices.

Depending on the distance, bit rate, and interface chips, as many as 256 nodes can be connected along a single pair of wires.

RS-485 is the interface described by a document titled TIA/EIA-485. A similar standard is ISO/IEC 8482.1993.

Page 4: Asynchronous interface

RS-485 advantages over RS2-32

Low cost: Driver & receivers are inexpensive and require just a single +5V supply to generate the required minimum 1.5V difference at the differential outputs.

Networking ability: Instead of being limited to two devices, RS-485 is multi drop interface that can have multiple drivers and receivers. With high impedance receivers, an RS-485 link can have as many as 256 nodes.

Long Links: A RS-485 link can be as long as 4000 Feet as compared to RS-232’s typical limit of 50 to 100 feet.

Speed: The bit rate can be as high as 10Mega Bits/Second. The cable length and the bit rate are related. Lower bit rates allow longer cables.

Page 5: Asynchronous interface

Balanced & Unbalanced lines

The main reason why RS-485 can transmit over long distances is because it uses balanced lines. Each signal has a dedicated pair of wires, with the voltage on one wire equal to the negative, or complement, of the voltage on the other. The receiver responds to the difference between the voltages. A big advantage to balanced lines is their immunity to noise. This is also called differential signaling.

In contrast, RS 232 uses unbalanced or single ended lines. The receiver responds to the difference between a signal voltage and a common ground used by all systems. An unbalanced interface may have multiple ground wires, but all of the signal grounds connect together.

TIA/EIA-485 designates the two lines in a differential pair as A and B. At the driver, a TTL logic-high input causes line A to be more positive than line B, while a TTL logic low input causes line B to be more positive than A.

Page 6: Asynchronous interface

Schematic representation

At the receiver if input A is more positive than input B, the TTL output logic is high and if the input B is more positive than input A , the TTL output is low logic.

Page 7: Asynchronous interface

Specification TIA/EIA 422-B TIA/EIA – 485

Transmission mode Balanced Balanced

Cable length @9 kbps, max.(feet) approximate

4000 4000

Cable length @ 10 Mbps max. feet, approximate

50 50

Data rate, max.(bits/sec)

10M 10M

Differential output(minimum volts)

+ 2 + 1.5

Differential output (maximum volts)

+ 10 +6

Receiver sensitivity

+ 0.2 +0.2

Driver load, minimum (ohms)

100 60

Maximum number of drivers

1 32 unit loads

Maximum number of receivers

10 32 unit loads

Page 8: Asynchronous interface

Why balanced lines are quiet

Balanced lines are quiet because the two signal wires carry nearly equal, opposite currents.

This reduces received noise because most noise voltages are present more or less equally on both wires.

A balanced receiver sees only the transmitted signal, with noise eliminated or very much reduced.

Another advantage to balanced lines is that they are immune, within limits, to differences in ground potential between the driver and receiver.

In a long link, the grounds at the driver and receiver may vary by many volts.

A balanced line doesn't care about mismatched grounds, because the receiver detects only the difference between the two transmitted signals.

Page 9: Asynchronous interface

Synchronous Communication

IIC

SPI

Page 10: Asynchronous interface

IIC

Page 11: Asynchronous interface

Term Description

Transmitter IIC device sending data to IIC bus (master or slave).

Receiver IIC device receiving data from IIC bus (master or slave).

Master The device which initiates a transfer, generates clock signals & terminates a transfer.

Slave The device addressed by the master.

Arbitration Procedure to ensure that, if more than one master simultaneously tries to control the bus, only one is allowed to do so and the winning message is not corrupted.

Synchronization Procedure to synchronize the clock signals of two or more devices.

Page 12: Asynchronous interface

Some IIC devices

I/O Expander devices. LCD & LED driver devices. Video controller. PAT/NTSC TV processors TV and VTR stereo/dual sound processors with integrated filters. Hi-Fi stereo audio processor interface for color decoder. YUV/RGB switches. Programmable modulators for negative-video modulation and FM

sound. Satellite sound receiver. 1.4 GHz multimedia synthesizer.

Page 13: Asynchronous interface

IIC Interface Principals

IIC is a synchronous serial bus developed by Phillips to allow communication between different peripherals.

Many devices such as EEPROMs, ADCs, LCD drivers, DACs etc support IIC protocol.

The devices on the bus communicate through a two wire interface. Typical data transfers are 100Kbits/Sec, 400Kbits/Sec and even 1Mbit/Sec.

The number of devices on the bus is limited by the maximum bus capacitance of 400pF.

Most devices are used as slaves while the microcontrollers are typically masters.

IIC also supports multi-mastering, which means more than one device is allowed to control the bus.

IIC has collision detection and arbitration to maintain data integrity.

Page 14: Asynchronous interface

IIC protocol

IIC is a multi-master/slave protocol. All devices connected to the bus must have an open-collector or open drain output.

A transaction begins when the bus is free (ie. both SCL and SDA are high).

A master initiates a transfer by generating a START condition. The master then sends an address byte that contains the slave address and the transfer direction.

The addressed slave device must acknowledge the master. If the transfer direction is from master to slave, the master becomes the transmitter and writes to the bus.

The slave becomes the receiver and reads the data and acknowledges the transmitter and vice-versa.

When the transfer is complete, the master sends a stop condition and the bus becomes free. In both transfer directions; the master generates the clock SCL and the START/STOP conditions.

Page 15: Asynchronous interface

IIC START/STOP conditions

Page 16: Asynchronous interface

The START condition is generated by a high to low transition on the SDA line during the High period of SCL line.

A STOP condition is generated by a low to high transition on the SDA line during the High period of the SCL line.

The number of bytes transferred per START/STOP frame is unrestricted.

DATA bytes must be 8-bits long with the most significant bit (MSB) first.

Each valid data bit sent to the SDA line must remain high for “1” or low for “0” during the high period of the SCL, otherwise any transition in the SDA line while SCL is high will be read as START/STOP condition.

Transitions can only be made during low period of SCL. An acknowledgement bit must follow each byte. After the last

bit of the byte is sent, an ACK clock (acknowledgement clock) is generated by the master (9th Clock). An ACK (acknowledge bit, low) must be sent by the receiver and remain low during the high period of the ACK clock.

Page 17: Asynchronous interface

If the slave (receiver) doesn’t return an ACK (e.g an error, or is unable to receive data), then the slave device must leave the SDA line high (NACK).

The master will abort transmission by generating a STOP condition.

The slave will need to keep the SDA line high for the master to generate the STOP condition.

If the receiver is the master and the transfer is ending then, the master needs to send NACK. The slave ( now transmitter) must release the SDA line to high, this allows the master to generate a START/STOP condition.

At the beginning of each transfer, the master generates the START condition, then sends a slave address. The standard slave address is 7 bit (sometimes 10 bit) followed by a direction or R/W bit (8th bit).

When the direction bit is a WRITE (zero), the addressed slave becomes the receiver and the master is the transmitter. When the direction bit is a READ (one), the addressed slave device becomes the transmitter and the master becomes the receiver.

Page 18: Asynchronous interface

Arbitration

A master may transfer only if the bus is free. Two or more masters may generate a start condition within the minimum hold time of the start condition. This results in a defined START condition to the bus.

Arbitration takes place on the SDA line, while SCL line is at high level. One master transmits a high level, while another master is transmitting a low level. The second master will switch off its DATA output stage because the level on the bus doesn’t correspond to its own level.

Arbitration can continue for many bits. Its first stage is comparison of the address bits. If the masters are each trying to address the same device, arbitration continues with the comparison of the data-bits. Address and data information on the IIC bus is determined by the winning master, no information is lost during the arbitration process.

A master that loses the arbitration can generate clock pulses until the end of the byte in which it loses the arbitration.

Page 19: Asynchronous interface

If a master also incorporates a slave function and it loses arbitration during the addressing stage, it's possible that the winning master is trying to address it. The losing master must therefore switch over immediately to its slave mode. The moment there is a difference between the internal data level of the master generating DATA 1 and the actual level on the SDA line, its data output is switched off, which means that a HIGH output level is then connected to the bus. This will not affect the data transfer initiated by the winning master.

Arbitration procedure of two masters

Page 20: Asynchronous interface

Since control of the IIC-bus is decided solely on the address or master code and data sent by competing masters, there is no central master, nor any order of priority on the bus.

Special attention must be paid during a serial transfer, if the arbitration procedure is still in progress at the moment when a repeated START condition or a STOP condition is transmitted to the IIC-bus. such a situation to occur, the masters involved must send this repeated START condition or STOP condition at the same position in the format frame.

In other words, arbitration isn't allowed between… A repeated START condition and a data bit A STOP condition and a data bit A repeated START condition and a STOP condition. Slaves are not

involved in the arbitration procedure.

Page 21: Asynchronous interface

A Complete data transfer

Page 22: Asynchronous interface

Possible data transfer formats

Master-transmitter transmits to slave-receiver. The transfer direction is not changed .

Master reads slave immediately after first byte. At the moment of the first acknowledge, the master- transmitter becomes a master- receiver and the slave-receiver becomes a slave-transmitter. This first acknowledge is still generated by the slave. The STOP condition is generated by the master, which has previously sent a not-acknowledge.

Page 23: Asynchronous interface

Combined format. During a change of direction within a transfer, the START condition and the slave address are both repeated, but with the R/W bit reversed. If a master receiver sends a repeated START condition, it has previously sent a not-acknowledge.

Page 24: Asynchronous interface

Definition of bits in the first byte The addressing procedure for the IIC-bus is such that the first byte

after the START condition usually determines which slave will be selected by the master.

When an address is sent, each device in a system compares the first seven bits after the START condition with its address. If they match, the device considers itself addressed by the master as a slave-receiver or slave-transmitter, depending on the R/W bit.

Page 25: Asynchronous interface

A slave address can be made-up of a fixed and a programmable part. Since it's likely that there will be several identical devices in a system, the programmable part of the slave address enables the maximum possible number of such devices to be connected to the IIC-bus. The number of programmable address bits of a device depends on the number of pins available.

The IIC-bus committee coordinates allocation of IIC addresses.

Page 26: Asynchronous interface

SLAVE ADDRESS R/WBIT DESCRIPTION

0000 000 0 General call address

0000 000 1 START byte<1>

0000 001 X CBUS address*2)

0000010 X Reserved for different bus format'3)

0000011 X Reserved for future purposes

0000 1XX X Hs-mode master code

1111 1XX X Reserved for future purposes

1111 OXX X 10-bit slave addressing

Page 27: Asynchronous interface

SPI Bus

Page 28: Asynchronous interface

Typical System

Page 29: Asynchronous interface

Introduction

SPI was developed by Motorola semiconductors. SPI uses a master-slave model and typically has three signal lines: data input line, data output line and clock line.

Chip select signals from the master are used to address different slaves on the bus. The hardware realization of such an interface is a simple shift register.

The data bits are shifted in/out MSB (most significant bit) first. Often

the data is shifted simultaneously out from the output pin and into the input pin.

SPI interface defines only the communication lines and the clock edge, other parameters vary for different devices. Clock frequencies happen to be anywhere from 100kHz to a few MHz and word lengths are from 8 to 16 or more bits.

Page 30: Asynchronous interface

Signal Description

4 basic signals…

MOSI,

MISO

SCLK

SS

Page 31: Asynchronous interface

MOSI, MISO,SCLK, SS Master Out, Slave In : An output line from master device and

input into slave device. MOSI line transfers data in one direction only from Master to Slave.

Master In Slave Out : An input line into the master device and output from slave device. MISO line transfers data in opposite direction in MOSI line, i.e. transfers data from a slave to master device.

Serial Clock : SCLK line used to synchronize both, data in and out of a device via MOSI, MISO lines. SCLK generated by master. Hence is input to all slave devices.

Slave select : SS lines are controlled by master to select slave device. Must be low prior to data transaction and must stay low for duration of transaction. Each slave device requires its own SS input line from the master.In slave device logic low received on SS line and clock input at SCLK pin. This synchronizes slave with the master. Data then is received serially at MOSI. During write cycle data shifted on to MISO pin on clock from master.

Page 32: Asynchronous interface

Signal Line Interconnections

Page 33: Asynchronous interface

SPI Operation

To initiate data transfer SS line must go low. This synchronizes the slave device with master. Data can be transferred between the master and slave in one of the two modes…

1) Data sampled at the raising edge of the clock2) Data sampled on the falling edge of the clock.

Page 34: Asynchronous interface

Features Full duplex, three-wire synchronous transfers Clock rate selectable up to 1.72MHz (2.5MHz possible with

slight modifications) Master send frequency adjustable up to 1.72 MHz Slave receive frequency adjustable upto 1.1 MHz Word length selectable anywhere from 1-16 bits. (More than 16 bits easily implemented if required) Clock polarity is configurable by using the appropriate

command byte This multimode capability combined with simple shift register

architecture makes the SPI bus very versatile. Due to this versatility many non-SPI serial devices including

most shift registers may be used as SPI slaves.

Page 35: Asynchronous interface

Clock Modes All data transferred by serial clock. 1 Bit of data is transferred for each clock cycle 4 versions of clock to data relationship are defined for the SPI bus. These versions, Mode A thru D are determined by value of clock

polarity (CPOL) and clock phase (CPHA) bits. Any hardware device capable of operating in more than one mode

will have some means of selecting the value of these bits. Clock polarity determines the level of clock idle state and clock

phase determines which clock edge places new data on the bus. Mode required for a given application generally determined by slave.

Page 36: Asynchronous interface

Clock Polarity CPOL

If CPOL cleared (logic 0) and no data is being transferred (idle state), the master holds SCK line low. If CPOL is set (logic 1) master idles the SCK line high.

Page 37: Asynchronous interface

Clock Phase CPHA

CPHA, in conjunction with CPOL, controls when data is placed on the bus (shifted out). If CPHA is set (logic 1) data shifted out on to MOSI line determined by the value of CPOL.

For CPHA set if CPOL is set new data is placed on the line at the down going clock and is read at the up going clock.

IC CPOL is cleared, new data is placed on the line at the up going clock and is read at the down going clock.

IF CPHA is cleared (logic 0) the shift clock is the OR of the SCK with SS. As soon as SS goes low, new data is placed on the line and the first edge of the clock reads the data.

IF CPOL is set the first clock edge is down going and subsequent data bits are read at each down going clock. Each new bit is placed on the line at the up going clock.

IF CPOL is cleared the first clock edge is up going and subsequent data bits are read at each up going clock. Each new bit is placed on the line at the down going clock.

Page 38: Asynchronous interface

SPI Data & CLK Timing - 1

Page 39: Asynchronous interface

SPI Data & CLK Timing - 2

Page 40: Asynchronous interface

SPI Data & CLK Timing - 4

Page 41: Asynchronous interface

Interfacing USB

A Practical Implementation

Chip Solutions

Microcontrollers with on-chip USB Hardware

Page 42: Asynchronous interface

A Practical Implementation…

Interfacing current generation printers Adding extended memory (USB Pen drive) Adding USB peripherals like modem’s etc

A synchronous two wire communication interface employing differential signaling technique, with hot plug in capabilities & device recognition. (MAX number of devices 127)

USB interface available in slow speed & High speed, USB (1.1 --- 1.5MBps) & USB (2.0 --- 12Mbps).

Page 43: Asynchronous interface

Electrical Specifications:

USB Transfers signal & power over a 4 wire cable. The actual communication is effected between (D+) & (D-), two wires and point to point segments. The signals on each segment are differentially driven into a cable of 90Ω intrinsic impendence.

The clock is transmitted encoded along with the differential data. The clock encoding scheme is NRZI (Non Return to Zero Inverted) with bit stuffing to ensure adequate transitions. A SYNC field precedes each packet to allow the receiver (s) to synchronize their bit recovery clocks.

In order to provide guaranteed input voltage levels and proper termination impedance, biased terminations are used at each end of the cable. The terminations also permit the detection of attach and detach at each port and differentiate between full speed and low speed devices.

Page 44: Asynchronous interface

BUS PROTOCOL:

Bus transactions involve the transmission of up to three packets. Each transaction begins when the host controller, on a scheduled basis, sends a USB packet describing the type and direction of transaction, the USB device address, and endpoint number. This packet is referred to as the Token Packet. The USB device that is addressed selects itself by decoding the appropriate address fields.

The source of the transaction then sends a Data Packet or indicates it has no data to transfer. The destination in general responds with a Handshake Packet indicating whether the transfer was successful.

Page 45: Asynchronous interface

The USB data transfer model between a source or destination on the host and an endpoint on a device is referred to as a pipe. There are two types of pipes: stream and message. Stream data has no USB defined structure while message data does. Additionally, pipes have associations of data bandwidth, transfer service type, and endpoint characteristics like directionality and buffer sizes.

Devices on the USB are physically connected to the host via a tiered star topology. USB attachment points are provided by a special class of USB device known as a hub. The additional attachment points provided by a hub are called ports. A host includes an embedded hub called the root hub.

Page 46: Asynchronous interface

Most-relevant USB classes …

• Mass Storage Device (MSD), • Human Interface Device (HID), • Device Firmware Upgrade (DFU), • Communication Device Class (CDC),

One of the major advantages of HID is that you do not need to supply a custom driver, as one is already supplied with the operating system. A limitation of HID is that its data transfer rate is limited to a maximum of 64KB per second. However, this is still significantly faster than RS-232 (115200 baud is approximately 12KB per second). In addition, modern embedded system designs are now using the USB Bus to connect a device to a PC, rather than a legacy system such as RS-232. On the other hand CDC, is a virtual comport implementation and can be read & written to as that of any standard PC Serial port.

Page 47: Asynchronous interface

Physical Bus Topology

Devices on the USB are physically connected to the host via a tiered star topology. USB attachment points are provided by a special class of USB device known as a hub. The additional attachment points provided by a hub are called ports.

To prevent circular attachments, a tiered ordering is imposed on the star topology of the USB. This results in the tree-like configuration

Page 48: Asynchronous interface

Logical Bus Topology

Page 49: Asynchronous interface

PIC 18F4550

PIC Devices with USB…

• 18F4550

Page 50: Asynchronous interface

ATMEL AVR Devices

The following devices have USB interface for applications needing to communicate with USB host.

AT90USB82: 8KB FlashAT90USB162: 16KB FlashAT90USB646: 64KB FlashAT90USB1286: 128KB Flash

The following devices comply with the USB On-The-Go (OTG) standard for use as Dual Role Devices (DRD) in applications operating as either host or function on the USB. The USB host capability is key to embedded devices needing to communicate without PC intervention.

AT90USB647: 64KB FlashAT90USB1287: 128KB Flash

Page 51: Asynchronous interface

Other USB Solutions

MAXIM SemiconductorsFTDITICypressSI Labs

Page 52: Asynchronous interface

USB Wizard OEM

A Philips LPC2103 based USB interface solution from GHI Electronics, also offering FAT32 file system

http://www.tracesystemsinc.com/usb_tools.ivnu

Page 53: Asynchronous interface

FTDI Chip Solutions…

FT232R:

The FT232R is the latest device to be added to FTDI’s range of USB UART interface Integrated Circuit Devices. The FT232R is a USB to serial UART interface with optional clock generator output, and the new FTDIChip-ID™ security dongle feature. In addition, asynchronous and synchronous bit bang interface modes are available. USB to serial designs using the FT232R have been further simplified by fully integrating the external EEPROM, clock circuit and USB resistors onto the device.

Page 54: Asynchronous interface

FT245

The FT245R is the latest device to be added to FTDI’s range of USB FIFO interface Integrated Circuit Devices.  The FT245R is a USB to parallel FIFO interface, with the new FTDIChip-ID™ security dongle feature.  In addition, asynchronous and synchronous bit bang interface modes are available.

Page 55: Asynchronous interface

Bluetooth…

Bluetooth is a telecommunications industry specification that describes how mobile phones, computers, and personal digital assistants (PDAs) can be easily interconnected using a short-range wireless connection.

Bluetooth requires that a low-cost transceiver chip be included in each device. The transceiver transmits and receives in a previously unused frequency band of 2.45 GHz that is available globally (with some variation of bandwidth in different countries).

In addition to data, up to three voice channels are available. Each device has a unique 48-bit address from the IEEE 802 standard. Connections can be point-to-point or multipoint. The maximum range is 10 meters. Data can be exchanged at a rate of 1 megabit per second (up to 2 Mbps in the second generation of the technology). A frequency hop scheme allows devices to communicate even in areas with a great deal of electromagnetic interference. Built-in encryption and verification is provided.

The technology got its unusual name in honor of Harald Bluetooth, king of Denmark in the mid-tenth century.

Page 56: Asynchronous interface

Bluetooth communication occurs between a master radio and a slave radio. Bluetooth radios are symmetric in that the same device may operate as a master and also the slave. Each radio has a 48-bit unique device address (BD_ADDR) that is fixed. Two or more radio devices together form ad-hoc networks called piconets. All units within a piconet share the same channel. Each piconet has one master device and one or more slaves. There may be up to seven active slaves at a time within a piconet. Thus, each active device within a piconet is identifiable by a 3-bit active device address. Inactive slaves in unconnected modes may continue to reside within the piconet.

Page 57: Asynchronous interface

The protocols & layers in Bluetooth stack

Link manager protocolLogical link control & adaptation protocolService discovery protocolTelephony control protocolRFCOMM protocolPPP protocolTCP/UDP/IPOBEX protocol

Page 58: Asynchronous interface

CAN

Page 59: Asynchronous interface

The CAN bus (Controller Area Networking) was defined in the late 1980 by Bosch, initially for use in automotive applications. It has the following characteristics:

• Uses  a single terminated twisted pair cable • Is multi master• Maximum Signal frequency used is 1 Mbit/sec • Length is typically 40M at 1Mbit/sec up to 10KM at 5Kbits/sec • Has high reliability with extensive error checking • Typical maximum data rate achievable is 40KBytes/sec• Maximum latency of high priority message <120 µsec at 1Mbit/sec

CAN is unusual in that the entities on the network, called nodes, are not given specific addresses.  Instead, it is the messages themselves that have an identifier which also determines the messages' priority.  For this reason there is no theoretical limit to the number of nodes although in practice it is ~64.

Page 60: Asynchronous interface

Signal Characteristics

CAN may be implemented over a number of physical media so long as the drivers are open-collector and each node can hear itself and others while transmitting (this is necessary for its message priority and error handling mechanisms).  The most common media is a twisted pair 5v differential signal which will allow operations in high noise environments and with the right drivers will work even if one of the wires is open circuit. 

When running Full CAN (ISO 11898-2) at its higher speeds it is necessary to terminate the bus at both ends with 120 Ohms.  The resistors are not only there to prevent reflections but also to unload the open collector transceiver drivers.

Page 61: Asynchronous interface

CAN and the ISO/OSI model

The CAN handles the two lowest levels in the standard model, i.e. the Physical Layer and the Data Link Layer. The CAN may be divided into three parts - physical, Logical Link Control (LLC), and Medium Access Control (MAC).

Page 62: Asynchronous interface

The Physical Layer & topology

CAN doesn't require a specific physical media, on which the transfer is actually done. That means that different media's may be used to connect CAN controllers, including twisted-pair and fiber-optic cables. What is important, is that there are two signal lines, termed CAN_H and CAN_L. A dominant (logical 0) CAN_L, and a recessive (logical 1) bit, in opposite, CAN_H lower than CAN_L. That mechanism yields to a reliable data transfer, even in an extremely harsh electrical environment..

Page 63: Asynchronous interface

CAN an international standard defined in the ISO 11898

                                                                                                                                                               CAN is based on the

Page 64: Asynchronous interface

Message formats

The CAN protocol uses a modified version of the Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) technique used on Ethernet.  Should two messages determine that they are both trying to send at the same time then instead of both backing off and re-trying later as is done with Ethernet, in the CAN scheme, the transmitters detect which message has the highest priority and only the lower priority message gets delayed.  This means that a high priority message is sure of getting through.

Page 65: Asynchronous interface

Message Frames

These are the normal frames used to carry data.  They contain the following fields -- this is a simplified description as the controller takes care of the detail which is only of interest to those designing controllers (who should consult the spec)

Start of frame   (SOF)Message Identifier  (MID)    either 11 or 29 bits long depending on the chosen modeRemote Transmission Request (RTR) = 0  ----- see "Remote Frames" para below for non zero valueControl field  (CONTROL)  this specifies the number of bytes of data to follow (0-8)Data Field (DATA)CRC field  containing a fifteen bit cyclic redundancy check codeAcknowledge field  (ACK)   an empty slot which will be filled by the receiving node on successful receptionEnd of Frame   (EOF)

The way in which message collision is avoided is that each node as it transmits its MID looks on the bus to see what everyone else is seeing.  If it is in conflict with a higher priority message identifier (one with a lower number) then the higher priority messages bit will hold the signal down (a zero bit is said to be dominant) and the lower priority node will stop transmitting. 

Page 66: Asynchronous interface

Remote Frames

These are frames that are used to request that a particular message be put on the network - of course a node somewhere on the network has to be set up to recognize the request, get the data and put out a Message frame. This mechanism is used in polled networks.  The fields are ....

• Start of frame   (SOF)• Message Identifier  (MID)    either 11 or 29 bits long depending on the chosen mode.• Remote Transmission Request (RTR)  = 1• Control field  (CTRL)  this specifies the number of bytes of data expected to be returned (0-8).• CRC field  containing a fifteen bit cyclic redundancy check code.• Acknowledge field  (ACK)   an empty slot which will be filled by the receiving node.• End of Frame   (EOF)

Page 67: Asynchronous interface

Error checking

CAN is a very reliable system with multiple error checks

Stuffing error  -  a transmitting node inserts a high after five consecutive low bits (and a low after five consecutive high). A receiving node that detects violation will flag a bit stuffing error.

Bit error  -  A transmitting node always reads back the message as it is sending. If it detects a different bit value on the bus than the one it sent, and the bit is not part of the arbitration field or in the acknowledgement field, an error is detected.

Checksum error - each receiving node checks CAN messages for checksum errors.

Frame error - There are certain predefined bit values that must be transmitted at certain points within any CAN Message Frame. If a receiver detects an invalid bit in one of these positions a

Form Error (sometimes also known as a Format Error) will be flagged.Acknowledgement Error - If a transmitter determines that a message has not been Acknowledged then an ACK Error is flagged.

Page 68: Asynchronous interface

MCP2515

18-pin package Simple SPI interface to any MCU One-shot mode ensures message transmission is attempted only once Databyte filtering Start-of-Frame (SOF) output Low-power CMOS Technology

Many microcontroller manufacturers have started to embedded CAN functions into the microcontrollers…

ATMEL AVR & 8051, PIC MICRO CHIP, TI, CYPRESS, SILABS etc…