Ch.12 Communication Systems - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Ch.12 Communication Systems

Description:

Without the FIFO, data will have to be processed one at a time. Timing Let tp be the time (in sec.) ... Half-duplex the frame can be echoed back. – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 34
Provided by: Geor4168
Category:

less

Transcript and Presenter's Notes

Title: Ch.12 Communication Systems


1
Ch.12 Communication Systems
  • Valvanos text

2
12.1 Introduction
  • SCI can be used to create a network.
  • Figure 12.1 gives a general visualization.
  • At lowest level frames are transferred between
    I/O ports, along the physical link.
  • At the next level the operating system of one
    computer sends a message or packet to the OS of
    another computer.
  • The message protocol will specify types and
    formats of the messages.

3
12. 1 (cont.)
  • Messages typically have
  • Addresses
  • Synchronization or handshake field
  • Data field
  • Error detection and correction field

4
12.1 (cont.)
  • Highest levelcommunications between users, or
    high level software tasks.

5
12.2 Reentrant Programming and Critical Sections
  • If two threads access the same global memory, and
    one is a write, then there is a causal dependency
    between the threads.
  • Shared global variables are important because
    they are required to pass data between threads.
  • Hard to find bugs.

6
12.2 (cont.)
  • A program segment is reentrant if it can be
    concurrently executed by two or more threads.
  • Implementation of reentrant program segments
    avoids storing in global memory.
  • Also, variables are placed in registers or on the
    stack.

7
12.2 (cont.)
  • A nonreentrant subroutine will have a section of
    code called a vulnerable window or critical
    section.
  • Errors
  • (1)One thread calls the non-reentrant subroutine
  • (2) It is executing in the critical section when
    interrupted by a second thread.
  • (3) The second thread calls the same subroutine.

8
12.2 (cont.)
  • Possibilities
  • The second thread is allowed to complete the
    execution of the subroutine, then the first
    thread finishes the subroutine.
  • The second thread executes part of the
    subroutine, is interrupted, and then re-entered
    by a third thread the third thread finishes, the
    second thread finishes, then control is passed to
    the first thread and it finishes.

9
12.2 (cont.)
  • Program 12.1 illustrates a non-reentrant
    function, since num is a global variable used by
    the functions (in assembly and C).
  • (In C) short num
  • short Ave (short first, short
    second)
  • num first
  • return (numsecond)/2
  • This is non-reentrant because of the access to a
    globalnum.

10
12.3 Interthread Communication and Synchronization
  • A simple inter-thread scheme is a mailbox.
  • Figure 12.2 illustrates an input device
    interfaced using interrupt synchronization.

11
12.3.4 Producer Consumer Problem
  • First In First Out (FIFO) circular Queue and
    double buffer.
  • Data Structures that can be used to link a
    source process (producer) with a sink process
    (consumer).
  • Fig. 12.4 (page 440)
  • Table 12.1 (examples of producers/consumers)

12
12.3.4 (cont.)
  • A first in first out circular queue (FIFO) is
    useful for the implementation of a buffered I/O
    interface.
  • After initialization, the queue puts and gets
    data.
  • This allows the foreground thread to run while a
    second thread runs in the background.

13
12.3.4
  • A data flow graph is shown in Figure 12.5.
  • There is buffered input and buffered output
    illustrated.
  • Valvanos textFIFOs are implemented using
    statically allocated global structures.
  • An advantage of the FIFO is that the producer and
    consumer threads can be decoupled this will
    improve system performance.
  • Without the FIFO, data will have to be processed
    one at a time.

14
Timing
  • Let tp be the time (in sec.) between calls to
    Put, and rp be the arrival rate (in bytes/sec)
    into the system.
  • Let tg be the time (in sec.) between calls to Get
    and rg be the service rate (in bytes/sec) out ot
    the system.

15
Timing (cont.)
  • Then rg 1/tg and rp 1/tp.
  • If min tp max tg, then a FIFO is not needed and
    a mailbox can be used.
  • If the average input rate is larger than the
    average ouput rate then a FIFO will eventually
    overflow, no matter how large the FIFO is.
  • But if rp is temporarily high or rg is
    temporarily low, (and the FIFO becomes full) then
    this problem can be solved by increasing the FIFO
    size.

16
Checkpoint 12.5
  • If the FIFO becomes full, can the situation be
    solved by increasing the size?
  • Answer
  • No, if the average producer rate exceeds the
    average consumer rate.
  • Yes, if the temporary producer rate exceeds the
    temporary consumer rate.

17
Figure 12.6
  • This shows FIFO queues that are used to pass data
    between threads.
  • OutChar is called by the main program when it
    wishes to output data.
  • InChar is called by the main program when it
    wishes to input data.

18
12.3.4 FIFO Queue Implementation
  • Figure 12.7 FIFO implementation with infinite
    memory.
  • Program 12.3 illustrates some code fragments.
  • Figures 12.8,12.9 showing Put and Get operations
    with a pointer wrap.

19
12.3.4Double Buffer
  • Figure 12.11 shows the storing of data in one
    buffer while data is read from a second buffer
    and processed.
  • A double buffer is two buffers of fixed size.
  • Example Disk (see figure.)
  • Disk has fixed size blocksbuffers are the size
    as the blocks.

20
12.4 Serial Port Interface Using Interrupt
Synchronization
  • Example connect to a PC serial port.
  • Baud rate must match.
  • FIFOs are used.
  • Initially just the receiver is armed.
  • Transmitter will be armed when data is available
    within the SCI_OutChar routine.
  • Interrupt occurs when new data arrives in the
    receiver data register, and an interrupt occurs
    when the transmit data register is empty.

21
Program 12.5
  • Page 448, implementations of an interrupting SCI
    interface.

22
12.5 Distributed Systems
  • Three simple communication systems using the SCI
    port.
  • If distances are short, half-duplex can be
    implemented with simple open collector or
    open-drain TTL-level logic.

23
System 1
  • Master-slave configuration
  • Master transmit output is connected to all slave
    receive inputs (Fig. 12.12, page 449)
  • Master broadcasts commands.
  • Slaves can respond, one at a time.
  • When Master transmits, it is to all slaves.
  • If slaves only transmit after being triggered by
    the master, there will be no collisions.

24
System 2 Ring Network
  • Transmitter and Receiver lines are connected in a
    circle.
  • Figure 12.13three microcomputers connected using
    the SCI in each.
  • Simple to build but slow performance (response
    time and bandwidth).
  • It is also difficult to add/subtract nodes.

25
System 3 Multi-drop
  • Figure 12.14, page 451
  • Software activates the SP483 Driver and outputs
    the frame.
  • Half-duplexthe frame can be echoed back.
  • Errors can also be discovered using parity checks
    or checksums.

26
Checkpoint 12.11
  • How can the transmitter detect a collision had
    corrupted its output?
  • ANSWER The frame sent by a transmitter is
    echoed to its own receiver. If the data does not
    match, or if thre are any framing or noise errors
    then a collision has occurred.

27
Checkpoint 12.12
  • How can the receiver detect a collision had
    corrupted its input?
  • ANSWER Parity could be used to detect
    collisions. Also the message could have a
    checksum added. Framing or noise errors can
    also indicate a collision.

28
12.6 Design an Implementation of a Controller
Area Network (CAN)
  • 12.6.1 CAN
  • A serial data communications bus
  • Used for real-time applications.
  • Operate at speeds up to 1 Mbps.
  • Error detection capabilities.
  • Developed by Robert Bosch for use in autos.
  • Now used in industrial automation and control
    applications.

29
12.6 CAN (cont.)
  • Has been standardizedISO 11989.
  • Figure 12.15CAN base system using 9S12s.
  • Can have up to 112 nodes.
  • Four Components
  • (1) Bus2-wiresCANH and CANL termination is a
    120ohm resistor.
  • (2) Transceivercan transmit and receive on the
    same channel.
  • (3) CAN Controller
  • (4) Software used to transmit and process data.

30
12.7 Integrated Circuit (I2C) Interface
  • Historically, users want microcontrollers to
    require less power and space for embedded
    systems application.
  • Two Ways
  • Integrate functionality into the microcontroller.
  • Reduce the number of I/O pins.
  • I2Cproposed by Phillips in the 1980s
    originally use to interface devices using
    2-wires.
  • 1998 v1 became an industry standard.

31
12.7 (cont.)
  • Figure 12.19shows network made of masters and
    slaves.
  • Both lines are bidirectional.
  • SCLserial clock line.
  • SDAserial data line.

32
12.8 Wireless Communications
  • Design concerns
  • Bandwidth
  • Distance
  • Topology
  • Security
  • Figure 12.26
  • Short Range Device
  • SPI interface is illustrated

33
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com