Overview - PowerPoint PPT Presentation

About This Presentation
Title:

Overview

Description:

Baud rate: Max speed of transmission of bits: ... serialPort.setSerialPortParams(9600, // change baud rate here. SerialPort.DATABITS_8, ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 19
Provided by: larry109
Category:
Tags: baud | overview

less

Transcript and Presenter's Notes

Title: Overview


1
Overview
  • Intro to Project 2 - Serial I/O RS232, USB
  • Assembly Language Programming
  • Using the LC-3 Simulator

2
Serial Connection

3
RS232
Connects DTE (Data Terminal Equipment or
Computer) to DCE (Data Communications
Equipment).

Signals
Null Modem Connections using control signals
(handshaking)
4
RS232
Signals

Carrier Detect (CD) Incoming signal from a
modem Data Set Ready (DSR) Incoming handshaking
signal controlled by DCE Received Data (RD)
Incoming Data (from a DCE to a DTE) Request To
Send (RTS) Outgoing flow control signal
controlled by DTE Transmitted Data (TD) Outgoing
Data (from a DTE to a DCE) Clear To Send (CTS)
Incoming flow control signal controlled by
DCE Data Terminal Ready (DTR) Outgoing
handshaking signal controlled by DTE Ring
Indicator (RI) Incoming signal from a modem
Signal Ground Common reference voltage
5
RS232
Full handshaking (again)

Faked Loop back Connections
6
RS232

Minimum Connection No handshaking
7
RS232
RS232 Cable and Lab Hookup

8
RS232
Serial Bit Transmission Baud rate Max
speed of transmission of bits Typically
110, 300, 1200, 2400, 4800, 9600, 19200
bits/sec Start bit A first bit
always of the same polarity for equipment to sync
on Data Bits The useful data
follows the start bit Typically 5, 6,
7, or 8 bits Parity Bit Even
Parity, Odd Parity, Mark parity, No Parity
Stop Bits The trailing bits after the
data and parity to ensure time to catch data
Typically 1, 1.5, or 2 bits

9
RS232
  • For Project 2 you will
  • Create a stream of ASCII characters,
  • Observe the transmission of the pulse stream,
  • Change the parameters of the transmission, and
  • Explain all aspects of the transmission.

10
RS232
Java Program to transmit Character stream
  • import java.io.
  • import javax.comm.
  • public class SimpleWrite
  • public static void main(String args) throws
    Exception
  • OutputStream outputStream
  • outputStream get_the_serial_port()
  • byte data 'a'
  • for (int i 0 i lt 1000 i)
  • outputStream.write(data)
  • System.out.println ("i " i)
  • Thread.sleep(1000) // milliseconds
  • public static OutputStream get_the_serial_port
    () throws Exception

11
LC-3 Assembly Language Syntax
  • Each line of a program is one of the following
  • an instruction
  • an assember directive (or pseudo-op)
  • a comment
  • Whitespace (between symbols) and case are
    ignored.
  • Comments (beginning with ) are also ignored.
  • An instruction has the following format

LABEL OPCODE OPERANDS COMMENTS
optional
mandatory
12
An Assembly Language Program
  • Program to multiply a number by the constant 6
  • .ORIG x3050
  • LD R1, SIX
  • LD R2, NUMBER
  • AND R3, R3, 0 Clear R3. It will
  • contain the product.
  • The inner loop
  • AGAIN ADD R3, R3, R2
  • ADD R1, R1, -1 R1 keeps track of
  • BRp AGAIN the iteration.
  • HALT
  • NUMBER .BLKW 1
  • SIX .FILL x0006

13
Assembler Directives
  • Pseudo-operations
  • do not refer to operations executed by program
  • used by assembler
  • look like instruction, but opcode starts with
    dot

Opcode Operand Meaning
.ORIG address starting address of program
.END end of program
.BLKW n allocate n words of storage
.FILL n allocate one word, initialize with value n
.STRINGZ n-character string allocate n1 locations, initialize w/characters and null terminator
14
Trap Codes
  • LC-3 assembler provides pseudo-instructions
    foreach trap code, so you dont have to remember
    them.

Code Equivalent Description
HALT TRAP x25 Halt execution and print message to console.
IN TRAP x23 Print prompt on console,read (and echo) one character from keybd.Character stored in R070.
OUT TRAP x21 Write one character (in R070) to console.
GETC TRAP x20 Read one character from keyboard.Character stored in R070.
PUTS TRAP x22 Write null-terminated string to console.Address of string is in R0.
15
LC-3 Editor / Simulator
Go to Authors Web page (http//www.mhhe.com/patt2
) Download LC-3 (LC301.exe) LC-3 Edit LC-3
Simulate Review Guide to Using the Windows
Version of the LC-3 Simulator and LC-3 Edit
16
Sample Program
  • Count the occurrences of a character in a
    file.Remember this?

17
Count the occurrences of a character in a file (1
0f 2).
  • Program to count occurrences of a character in
    a file.
  • Character to be input from the keyboard.
  • Result to be displayed on the monitor.
  • Program only works if no more than 9
    occurrences are found.
  • Initialization
  • .ORIG x3000
  • AND R2, R2, 0 R2 is counter, initially 0
  • LD R3, PTR R3 is pointer to character file
  • GETC R0 gets input character
  • LDR R1, R3, 0 R1 gets first character from
    file
  • Test character for end of file
  • TEST ADD R4, R1, -4 Test for EOT (ASCII x04)
  • BRz OUTPUT If done, prepare the output

18
Count the occurrences of a character in a file (2
of 2).
  • Output the count.
  • OUTPUT LD R0, ASCII Load the ASCII template
  • ADD R0, R0, R2 Covert binary count to ASCII
  • OUT ASCII code in R0 is displayed.
  • HALT Halt machine
  • Storage for pointer and ASCII template
  • ASCII .FILL x0030 ASCII offset
  • PTR .FILL x4000 PTR to character file
  • .END
Write a Comment
User Comments (0)
About PowerShow.com