1 / 28

Serial Communication I

Serial Communication I. Overview. Serial Transmission, UARTs System Management Bus a.k.a. SMB/I2C Serial Peripheral Interface Bus a.k.a. SPI. Serial Transmission of Data. parallel. receiver. sender. serial. sender. receiver. Serial Data Transmission. serial. Receiver must know

steven-goff
Download Presentation

Serial Communication I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Serial Communication I EE/CS-352: Embedded Microcontrollers Systems

  2. Overview • Serial Transmission, • UARTs • System Management Bus a.k.a. SMB/I2C • Serial Peripheral Interface Bus a.k.a. SPI EE/CS-352: Embedded Microcontrollers Systems

  3. Serial Transmission of Data parallel receiver sender ... serial sender receiver EE/CS-352: Embedded Microcontrollers Systems

  4. Serial Data Transmission serial • Receiver must know • when transmission begins • when transmission ends • if data was transferred correctly sender receiver EE/CS-352: Embedded Microcontrollers Systems

  5. Asynchronous Communication • Sender and receiver agree on a common data transfer rate (BAUD rate) Half-duplex (one way) sender receiver sender /receiver receiver /sender Full-duplex (two ways) EE/CS-352: Embedded Microcontrollers Systems

  6. Synchronous Serial Communication • Common clock between sender and receiver • In 8051 can implement synchronous serial communication with • UARTs • SMB – System Management Bus • SPI – Serial Peripheral Interface data sender clock receiver EE/CS-352: Embedded Microcontrollers Systems

  7. Serial Communication with 8051 • UART0 and UART1 • SPI – Serial Peripheral Interface • SMB – System Management Bus • In all of these subsystems, program writes data in parallel to a SFR, and the subsystem controls the serial transfer of data. EE/CS-352: Embedded Microcontrollers Systems

  8. Serial Transmission • Synchronous • common clock wire used to synchronize • data sent in multiple bytes (relatively fast) • Asynchronous • most widely used for PC communication • no common clock wire between sender/receiver • data sent in individual bytes • simple, high overhead, (relatively slow) First look at this EE/CS-352: Embedded Microcontrollers Systems

  9. A. Synchrononus Communication EE/CS-352: Embedded Microcontrollers Systems

  10. Synchronous Communication with UART EE/CS-352: Embedded Microcontrollers Systems

  11. Synchronous Communication with UART data RxD UART0 TxD clock EE/CS-352: Embedded Microcontrollers Systems

  12. UART0 Synchronous Mode • Can either transmit or receive. • Clock rate is fixed at SYSCLK/12 • Data transmission begins when an instruction writes a data byte to the SBUF0 register. • Data reception begins when the REN0 Receive Enable bit (SCON0.4) is set to logic 1 and the RI0Receive Interrupt Flag (SCON0.0) is cleared. EE/CS-352: Embedded Microcontrollers Systems

  13. Synchronous Serial Interface Data Transmission example – TO a shift register 8-bits are transferred, LSB first, and 8 clock cycles sent IN Note only TWO wires are needed – not 8 EE/CS-352: Embedded Microcontrollers Systems

  14. Synchronous Serial Interface Data Transmission example – FROM a shift register 8 clock cycles sent, 8-bits are transferred, LSB first OUT EE/CS-352: Embedded Microcontrollers Systems

  15. Serial Communication with System Management Bus (SMB) EE/CS-352: Embedded Microcontrollers Systems

  16. SMB – SMBus0 • 2-wire, bidirectional serial bus • Compliant with standards: • System Management Bus v1.1 • I2C serial bus • SMBus0 can operate as master or slave • SCL and SDA must be pulled high when bus is free Vdd serial data SDA SMBus0 serial clock SCL EE/CS-352: Embedded Microcontrollers Systems

  17. SMB Protocol • A typical SMBus transaction consists of: • a START condition followed by • an address byte (Bits7-1: 7-bit slave address; Bit0: R/W direction bit), • one or more bytes of instruction/data, and a • STOP condition. • Each byte that is received (by a master or slave) must be acknowledged (ACK) with a low SDA during a high SCL. • If the receiving device does not ACK, the transmitting device will read a “not acknowledge” (NACK), which is a high SDA during a high SCL. serial data SDA SMBus0 serial clock SCL EE/CS-352: Embedded Microcontrollers Systems

  18. SMBus0 – Typical Configuration Voltage levels somewhat flexible EE/CS-352: Embedded Microcontrollers Systems

  19. SMB – Timing Diagram • SMB protocol also specifies • arbitration • timeouts EE/CS-352: Embedded Microcontrollers Systems

  20. SMB0 Registers • SMB0CN Control Register • SMB0CR Clock Rate Register • SMB0ADR Address Register • SMB0DAT Data Register • SMB0STA Status Register EE/CS-352: Embedded Microcontrollers Systems

  21. SMB Registers: SMB0CN Control Register • BUSY – SMB status flag (1=busy, 0=free) • ENSMB – SMB enable (1=enable, 0=disable) • STA – SMB start flag (1=transmit start) • STO – SMB stop flag (1=transmit stop) • SI – SMB Serial Interrupt flag (must be cleared by software) • AA – SMB Assert Acknowledge flag (for sending “ack” or “nack” • FTE – Free Time Enable (1=disable on timeout) • TOE – Timeout Enable (1=enable timeout for SCL low) EE/CS-352: Embedded Microcontrollers Systems

  22. SMB Registers: SMB0CRClock Rate Register • Controls the SCL clock rate • Reloads an 8-bit counter that toggles SCL • Limit: SMB0CR < (288 - 0.85.SYSCLK)/1.125 • TLOW = (256 - SMB0CR)/SYSCLK • THIGH =(258- SMB0CR/SYSCLK) +625ns Example: for 2 MHz sysclk and SMB0CR=0: TLOW = 128us, THIGH = 129us EE/CS-352: Embedded Microcontrollers Systems

  23. SMB Registers: SMB0DAT DATA Register • Data shifted out (on SDA) MSB (bit 7) first EE/CS-352: Embedded Microcontrollers Systems

  24. SMB/I2C Protocol • The master initiates data transfer by establishing a START condition, which is a high-to-low transition on SDA while SCL is high • The following byte is the slave address byte, which consists of the slave address followed by an R/W bit (0=write, 1=read) • Slave must put ACK (low) on bus to acknowledge • The next byte (or more) is a data byte • Master sends a “STOP” signal at end of data data instruction 7-bit address ACK start R/W EE/CS-352: Embedded Microcontrollers Systems

  25. SMB/I2C Protocol on C8051F020 • Interrupts are generated after an action has been performed • There is a status code associated with each of the actions • In our code, we will poll to determine if the interrupt flag is set and this will allow us to move to the next stage EE/CS-352: Embedded Microcontrollers Systems

  26. SMB/I2C Protocol on C8051F020 Master Transmitter Mode EE/CS-352: Embedded Microcontrollers Systems

  27. Serial Port Pins • Crossbar used to route serial pins to Ports Serial pins connected to Port 0 UART has highest priority If UART, SPI, and SMB are all enabled, pins assigned as indicated EE/CS-352: Embedded Microcontrollers Systems

  28. Communicate Serially with a Resistor! EE/CS-352: Embedded Microcontrollers Systems

More Related