《美国哥伦比亚大学嵌入式系统课件serial-communication》由会员分享,可在线阅读,更多相关《美国哥伦比亚大学嵌入式系统课件serial-communication(22页珍藏版)》请在金锄头文库上搜索。
1、Serial CommunicationStephen A. EdwardsColumbia UniversitySpring 2012Early Serial CommunicationLater Serial CommunicationData Terminal EquipmentData Communication EquipmentRS-232Defined in early 1960s Serial, Asynchronous, Full-duplex, Voltage-based, point-to-point, 100 ft+ cables+12V+3VSPACE = 03V12
2、VMARK = 1Idle Start LSBB1B2B3B4B5B6 MSB StopRS-232 SignalsSignalDTE . Meaning pinDCE RxD2Data received by DTE TxD3Data sent by DTE SG5Ground DSR6Data Set Ready (Im alive) DTR4Data Terminal Ready (me, too) DCD1Carrier Detect (hear a carrier) RTS7Request To Send (Yo?) CTS8Clear To Send (Yo!) RI9Ring I
3、ndicatorReceiving RS-232Idle Start LSBB1B2B3B4B5B6 MSB StopRxClkStart SampleSampleSampleSampleMost UARTs actually use 16 clocksVariantsParity bit: (Even = true when even number of 1s)Idle Start LSBB1B2B3B4B5B6MSB Parity StopTwo stop bits:Idle Start LSBB1B2B3B4B5B6MSB Stop StopBaud RateBaud: bits per
4、 secondBaudApplication110ASR-33 Teletype 300Early acoustic modems 1200Direct-coupled modems c. 1980 2400Modems c. 1990 9600Serial terminals 19200 38400Typical maximumPhysical VariantsConnectors: DB-25, DB-9, Mini DIN-8RS-422: Differential signalingRS-485: Bus-likeThe I2C BusPhilips invented the Inte
5、r-IC bus c. 1980 as a very cheap way to communicate slowly among chipsE.g., good for setting control registers100, 400, and 3400 kHz bitratesSCL: Clock, generated by a single masterSDA: Data, controlled by either master or slavesI2C Bus TransactionSCLSDAIdleStart01AckStopUSB: Universal Serial Bus 1.
6、5 Mbps, 12 Mbps, and 480 Mbps (USB 2.0) Point-to-point, differential, twisted pair 35m maximum cable lengthUSB ConnectorsUSB signalingNRZI: 0 = toggle, 1 = no changeBit stuffing: 0 automatically inserted after six consecutive 1sEach packet prefixed by a SYNC field: 3 0s followed by two 1sLow- vs. fu
7、ll-speed devices identified by different pull-ups on D+/D- linesUSB PacketsAlways start with SYNCThen 4-bit type, 4-bit type complemented2 bits distinguish Token, Data, Handshake, and Special, other two bits select sub-typesThen data, depending on packet typeData checked using a CRCAddresses (1-128)
8、 assigned by bus master, each with 16 possible endpointsUSB Bus ProtocolPolled bus: host initiates all transfers.Most transactions involve three packets:?“Token” packet from host requesting data?Data packet from target?Acknowledge from hostSupports both streams of bytes and structured messages (e.g.
9、, control changes).USB Data Flow Types?ControlFor configuration, etc.?Bulk Data Arbitrary data stream: bursty?Interrupt Data Timely, reliable delivery of data. Usually events.?Isochronous Data For streaming real-time transfer: prenegotiated bandwidth and latencyLayered ArchitectureUSB: Flash Card De
10、viceBus 001 Device 002: ID 05e3:0760 Genesys Logic, Inc. bcdUSB2.00 bMaxPacketSize064 idVendor0x05e3 Genesys Logic, Inc. idProduct0x0760 bcdDevice1.14 iManufacturer2 Genesys iProduct3 Flash Reader iSerial4 002364 Configuration Descriptor: bNumInterfaces1 MaxPower300mA Interface Descriptor: bNumEndpo
11、ints2 bInterfaceClass8 Mass Storage bInterfaceSubClass6 SCSI bInterfaceProtocol80 Bulk (Zip) Endpoint Descriptor: bEndpointAddress0x81EP 1 IN bmAttributes2 Transfer TypeBulk Synch Typenone wMaxPacketSize64 Endpoint Descriptor: bLength7 bDescriptorType5 bEndpointAddress0x02EP 2 OUT bmAttributes2 Tran
12、sfer TypeBulk Synch Typenone wMaxPacketSize64 Language IDs: (length=4) 0409 English(US)USB: Mouse DeviceBus 002 Device 002: ID 04b4:0001 Cypress Semiconductor Mouse Device Descriptor: bcdUSB1.00 idVendor0x04b4 Cypress Semiconductor idProduct0x0001 Mouse bcdDevice4.90 iManufacturer1 AdomaxSem. iProdu
13、ct2 USB Mouse iSerial0 Configuration Descriptor: bNumInterfaces1 bmAttributes0xa0 Remote Wakeup MaxPower100mA Interface Descriptor: bNumEndpoints1 bInterfaceClass3 Human Interface Devices bInterfaceSubClass1 Boot Interface Subclass bInterfaceProtocol2 Mouse iInterface5 EndPoint1 Interrupt Pipe HID D
14、evice Descriptor: bDescriptorType34 Report wDescriptorLength52 Endpoint Descriptor: bEndpointAddress0x81EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Typenone wMaxPacketSize4 bInterval10 Language IDs: (length=4) 0409 English(US)Philips ISP1362 USB 2.0 ControllerPhilips ISP1362 USB 2.0 ControllerOn the DE2, one downstream port, one hostOperates at 12 or 480 Mbps speedsTwo control endpoints + 14 user endpoints4096 (host) + 2462 (device) bytes buffer memorySupports DMA data transfersMany configuration and status registers150-page data “sheet” + 99-page embedded programming guide