1 / 35

EET 2261 Unit 10 Timers; Pulse Width Modulation

EET 2261 Unit 10 Timers; Pulse Width Modulation. Read Almy , Chapters 20 and 21. Homework #10 and Lab #10 due next week. Quiz next week. Communicating with External Devices.

roddy
Télécharger la présentation

EET 2261 Unit 10 Timers; Pulse Width Modulation

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. EET 2261 Unit 10Timers; Pulse Width Modulation • Read Almy, Chapters 20 and 21. • Homework #10 and Lab #10 due next week. • Quiz next week.

  2. Communicating with External Devices • We’ve used the HCS12’s general-purpose I/O ports (Ports A, B, E,…) to communicate with simple devices, such as switches and LEDs, that use standard TTL-level signals (0 V for LOW and 5 V for HIGH). • In addition to this low-tech form of communication, our HCS12 contains many blocks that implement more complicated communication bus standards.

  3. Serial Communications Interface (SCI) Blocks on the HCS12 • The HCS12 has two asynchronous serial communications interface blocks named SCI0 & SCI1. • Each SCI block has two I/O pins: RxDfor receiving data, TxDfor transmitting data. These pins are shared with the general-purpose I/O port S. • Figure from p. 6 of textbook or page 23 of Device User Guide).

  4. SCI0 and SCI1 on the Dragon12 • On the Dragon12 board: • The HCS12’s SCI0 is normally connected to the board’s USB port, through which the chip communicates with CodeWarrior on the personal computer. • The HCS12’s SCI1 is normally connected to the RS232 interface. • The board has movable jumpers that let us reconfigure the board’s communication resources for different needs.

  5. Block Diagram of Serial Communications Interface (SCI) Block • See block diagram on p. 12 of the SCI Block User Guide.

  6. Special-Function Registers Associated with the SCI Block • The 8 special-function registers located at addresses $00C8 to $00CF let us control the operation of the SCI0 block. • The 8 registers at addresses $00D0 to $00D7 are for the SCI1 block. • See p. 37 of Device User Guide.

  7. SCI Baud Rate Registers (SCIBDH and SCIBDL) • These two registers combined hold 16 bits, of which 13 form a number called SBR. • The SCI’s baud rate depends on SBR and the system’s bus clock frequency, as follows: Baud rate = Bus clock freq / (16 × SBR) • Figure from p. 5 of SCI Block User Guide.

  8. Possible Baud Rates • As stated on the previous slide, the HCS12’s baud rate is given by Baud rate = Bus clock freq / (16 × SBR)where SBR is a 13-bit number. • So it’s usually not possible to set the HCS12’s baud rate exactly to one of the standard values used by other communications devices (such as 300, 600, 1200, 2400, 4800, 9600, 19200). • But usually we can get close enough for communication to take place successfully.

  9. SCI Data Registers (SCIDRH and SCIDRL) • These registers hold the data that is being either transmitted or received. • For 8-bit data (the most common situation), only SCIDRL is used. • Figure from p. 11 of SCI Block User Guide.

  10. SCI Control Register 1 (SCICR1) • The bits we care most about in this control register are: • M, which we use to specify whether we’re working with 8-bit or 9-bit data. • PE, which we use to enable or disable parity generation/checking. • PT, which (if parity is enabled) we use to specify whether even or odd parity is used. • Figure from p. 6 of SCI Block User Guide.

  11. SCI Control Register 2 (SCICR2) • The bits we care most about in this control register are: • TE, which we use to enable or disable data transmission. • RE, which we use to enable or disable data reception. • Figure from p. 7 of SCI Block User Guide.

  12. SCI Status Register 1 (SCISR1) • The bits we care most about in this status register are: • TDRE, which tells us whether the transmission data register is empty. • RDRF, which tells us whether the receive data register is full. • Figure from p. 8of SCI Block User Guide.

  13. Steps for Transmitting Data • Programming the SCI to transmit data: • Set baud rate using SCIBDH:SCIBDL registers. • Write $00 to SCICR1 register, indicating 8-bit data frame, no parity bit. • Write $08 to SCICR2 register to enable transmission, also disabling interrupts. • Monitor the TDRE bit of the SCISR1 register to make sure data register is empty before sending a byte to SCIDRL. If TDRE = 1, then go to the next step. • Write the byte to be transmitted to SCIDRL. • To transfer another byte, go to Step 4.

  14. Steps for Receiving Data • Programming the SCI to receive data: • Set baud rate using SCIBDH:SCIBDL registers. • Write $00 to SCICR1 register, indicating 8-bit data frame, no parity bit. • Write $04 to SCICR2 register to enable reception, also disabling interrupts. • Monitor the RDRF bit of the SCISR1 register to see if an entire byte has been received. If RDRF = 1, then go to the next step. • Read the received byte from SCIDRL. • To receive another byte, go to Step 4.

  15. Microsoft HyperTerminal • A Microsoft Windows accessory program named HyperTerminal lets you send or receive data over your computer’s RS-232 port. • Shown here is a dialog box for configuring HyperTerminal.

  16. Review: Communicating with External Devices • In previous weeks we used the HCS12’s general-purpose I/O ports (Ports A, B, E,…) to communicate with simple devices, such as switches and LEDs, that use standard TTL-level signals (0 V for LOW and 5 V for HIGH). • In addition to this low-tech form of communication, our HCS12 contains many blocks that implement more complicated communication bus standards.

  17. Communication Blocks in the HCS12 • These blocks include: • Two serial communications interface (SCI) blocks. • Three serial peripheral interface (SPI) blocks. • Two controller area network (CAN) blocks. • One inter-integrated circuit (IIC) block. • Figure from p. 6 of textbook or page 23 of Device User Guide).

  18. Two Meanings of “Bus” • Sometimes the term bus simply refers to a group of conductors (wires or circuit board traces) that carry signals from one device to another. • Examples: address bus, data bus • At other times it refers to a standard set of specifications (voltage levels, timing specs, connectors, etc.) used for communication between devices. • Examples: RS-232, SPI, USB

  19. Many Bus Standards • There are dozens of bus standards in common use. From Wikipedia’s article on the USB bus:

  20. We’ll Start with the SCI Blocks • With all of these HCS12 blocks and bus standards, this is a large and complex topic. • We’ll restrict our attention the HCS12’s SCI blocks (Chapter 24) its SPI blocks (Chapter 25), and its IIC block (Chapter 26).

  21. Terminology: Serial vs. Parallel • Some bus standards apply to serial communication (1 data bit transferred at a time). • Others apply to parallel communication (several data bits—usually 8—transferred at a time).

  22. Terminology: Bits per Second and Baud Rate • These are two common measures of speed in communications. Many writers loosely treat these as being synonyms, but this is not strictly correct. • Bits per second (bps) is the easier to understand. Often expressed as kbps or Mbps. • In the simplest cases, baud rate equals bps. In more sophisticated schemes, the two are related but not equal. Traditional baud rates are 300, 600, 1200, 2400, 4800, 9600, 19200.

  23. Terminology: Simplex vs. Duplex • Simplex: Information flows in one direction only. • Example: a temperature sensor sending data to a personal computer. • Half-duplex: Information can flow in both directions, but only one at a time. • Example: walkie-talkie. • Full-duplex: Information can flow in both directions at the same time. • Example: telephone.

  24. Communications Terminology: Asynchronous vs. Synchronous • In asynchronous communication, the two devices do not share clock signals, so they use “handshaking” signals or some other method to coordinate their activity. • Widely used serial asynchronous standards: • RS-232 • RS-423 • RS-422 • RS-485 • USB (Universal Serial Bus): can operate synchronously or asynchronously.

  25. Communications Terminology: Asynchronous vs. Synchronous • In synchronous communication, the sender and receiver share a clock signal. • Widely used serial synchronous standards: • SPI (“four-wire,” or “three-wire” variant) • IIC or I2C (also called “two-wire”) • 1-wire

  26. Ports on a Typical Laptop Computer RS-232(Serial) USB(Serial) PS/2 Mouse (Serial) IEEE 1394(Serial) Printer (Parallel) VGA (Analog video)

  27. Ports on a Fluke 45 DMM IEEE 488 (“GPIB”) option not installed (Parallel) RS-232(Serial)

  28. RS-232 Standard • First version created in early 1960’s. • Obsolete in some respects, but still very widely used. • In recent years, has been applied in ways that its original creators never imagined, sometimes leading to problems. • Original spec defined 25 pins (signals), but often only 9 or fewer are used.

  29. Terminology: DCEvsDTE • In any RS-232 application, each device is designated as either Data Terminal Equipment (DTE) or Data Communications Equipment (DCE). • Simple case: When you connect a personal computer to a modem, the computer is the DTE and the modem is the DCE.

  30. Connectors • Original RS-232 standard called for a DB-25 connector. Since many later applications didn’t use most of the pins, it became common to use DE-9 connectors (often incorrectly referred to as DB-9).

  31. RS-232 Signals • The nine most important signals:

  32. RS-232 Voltage Levels • TTL voltage levels are: •  0 V for a binary 0. •  +5 V for a binary 1. • This scheme is “unipolar” because it doesn’t use negative voltages. • For transmission over a cable, it’s undesirable to have either logic level close to 0 V. • So RS-232 uses a “bipolar” scheme, with: • +3 V to +25 V for a binary 0 (“space”) • -3 V to -25 V for a binary 1 (“mark”)

  33. MAX232 Chip • Since TTL voltage levels are incompatible with RS-232 voltage levels, many digital systems need to translate from one to the other. • A popular chip for this purpose is Maxim’s MAX232A.

  34. RS-232 on the Dragon12 • The Dragon12 board contains an RS-232 interface, which consists of a MAX232A chip and a DE9 connector. • See the Dragon12 Schematic Diagram 3.

  35. HCS12 Uses a Scaled-Down RS-232 Interface • Recall from earlier that the RS-232 standard defines 25 lines, but that most applications get by with fewer than 25. • With the HCS12’s Serial Communications Interface, we use only three lines: RxD, TxD, and Signal Ground. • So we’re not using any of the handshaking lines (such as CTS, RTS, DSR, DTR).

More Related