3 About RS-485When 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
4 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.
5 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.
6 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.
7 SpecificationTIA/EIA 422-BTIA/EIA – 485Transmission modeBalancedCable kbps, max.(feet) approximate4000Cable 10 Mbps max. feet, approximate50Data rate, max.(bits/sec)10MDifferential output(minimum volts)+ 2+ 1.5Differential output (maximum volts)+ 10+6Receiver sensitivity+ 0.2+0.2Driver load, minimum (ohms)10060Maximum number of drivers132 unit loadsMaximum number of receivers10
8 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.
11 TermDescriptionTransmitterIIC device sending data to IIC bus (master or slave).ReceiverIIC device receiving data from IIC bus (master or slave).MasterThe device which initiates a transfer, generates clock signals & terminates a transfer.SlaveThe device addressed by the master.ArbitrationProcedure 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.SynchronizationProcedure to synchronize the clock signals of two or more devices.
12 Some IIC devices I/O Expander devices. LCD & LED driver devices. Video controller.PAT/NTSC TV processorsTV 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.
13 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.
14 IIC protocolIIC 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.
16 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.
17 If the slave (receiver) doesn’t return an ACK (e 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.
18 ArbitrationA 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.
19 Arbitration procedure of two masters 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.
20 In other words, arbitration isn't allowed between… 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 bitA STOP condition and a data bitA repeated START condition and a STOP condition. Slaves are not involved in the arbitration procedure.
22 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.
23 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.
24 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.
25 A slave address can be made-up of a fixed and a programmable part 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.
26 SLAVE ADDRESSR/WBITDESCRIPTIONGeneral call address1START byte<1>XCBUS address*2)Reserved for different bus format'3)Reserved for future purposes0000 1XXHs-mode master code1111 1XX1111 OXX10-bit slave addressing
29 IntroductionSPI 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.
30 Signal Description4 basic signals…MOSI,MISOSCLKSS
31 MOSI, MISO,SCLK, SSMaster 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.
33 SPI OperationTo 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…Data sampled at the raising edge of the clockData sampled on the falling edge of the clock.
34 Features Full duplex, three-wire synchronous transfers Clock rate selectable up to 1.72MHz (2.5MHz possible with slightmodifications)Master send frequency adjustable up to 1.72 MHzSlave receive frequency adjustable upto 1.1 MHzWord length selectable anywhere from 1-16 bits.(More than 16 bits easily implemented if required)Clock polarity is configurable by using the appropriate command byteThis 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.
35 Clock Modes All data transferred by serial clock. 1 Bit of data is transferred for each clock cycle4 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.
36 Clock Polarity CPOLIf 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.
37 Clock Phase CPHACPHA, 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.
41 Interfacing USB A Practical Implementation Chip Solutions Microcontrollers with on-chip USB Hardware
42 A Practical Implementation… Interfacing current generation printersAdding extended memory (USB Pen drive)Adding USB peripherals like modem’s etcA 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 ( MBps) & USB ( Mbps).
43 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.
44 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.
45 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.
46 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 ( 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.
47 Physical Bus TopologyDevices 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
50 ATMEL AVR DevicesThe following devices have USB interface for applications needing to communicate with USB host.AT90USB82: 8KB Flash AT90USB162: 16KB Flash AT90USB646: 64KB Flash AT90USB1286: 128KB FlashThe 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 Flash AT90USB1287: 128KB Flash
51 Other USB SolutionsMAXIM SemiconductorsFTDITICypressSI Labs
52 USB Wizard OEMA Philips LPC2103 based USB interface solution from GHI Electronics, also offering FAT32 file system
53 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.
54 FT245The 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.
55 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.
56 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.
57 The protocols & layers in Bluetooth stack Link manager protocolLogical link control & adaptation protocolService discovery protocolTelephony control protocolRFCOMM protocolPPP protocolTCP/UDP/IPOBEX protocol
59 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 cableIs multi masterMaximum Signal frequency used is 1 Mbit/secLength is typically 40M at 1Mbit/sec up to 10KM at 5Kbits/secHas high reliability with extensive error checkingTypical maximum data rate achievable is 40KBytes/secMaximum latency of high priority message <120 µsec at 1Mbit/secCAN 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.
60 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 ) 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.
61 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).
62 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..
63 CAN an international standard defined in the ISO 11898 CAN is based on the
64 Message formatsThe 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.
65 Message FramesThese 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.
66 Remote FramesThese 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) = 1Control 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)
67 Error checkingCAN is a very reliable system with multiple error checksStuffing 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 aForm 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.
68 MCP2515 18-pin package Simple SPI interface to any MCU One-shot mode ensures message transmission is attempted only onceDatabyte filteringStart-of-Frame (SOF) outputLow-power CMOS TechnologyMany microcontroller manufacturers have started to embedded CAN functions into the microcontrollers…ATMEL AVR & 8051, PIC MICRO CHIP, TI, CYPRESS, SILABS etc…