PIC Serial Port Interfacing

Slides:



Advertisements
Similar presentations
EUSART Serial Communication.
Advertisements

ECT 357 Ch 18 UART. Today’s Quote: Be careful that your marriage doesn’t become a duel instead of a duet. Be careful that your marriage doesn’t become.
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
DATA COMMUNICATIONS Some organisations concerned with standards: EIA - Electroonic Industries Association (RS standards including RS-232) IEEE - Institute.
Serial I/O - Programmable Communication Interface
Starting with serial Chapter Ten 10.1, 10.2,
Eng. Husam Alzaq The Islamic Uni. Of Gaza
COMP3221: Microprocessors and Embedded Systems
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
ECE 371- Unit 11 Introduction to Serial I/O. TWO MAJOR CLASSES OF SERIAL DATA INTERFACES ASYNCHRONOUS SERIAL I/O - USES “FRAMING BITS” (START BIT AND.
EEE305 Microcontroller Systems Lecture 7: Embedded C using PIC microcontrollers Serial i/o with the XC8 Teaching resources are at
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
University of Tehran 1 Interface Design Serial Communications Omid Fatemi.
Technology Training that Works Hands of Data Communications, Networking & TCP/IP Troubleshooting.
Serial Communication ETEC 6416.
The 8051 Microcontroller and Embedded Systems
Serial Port I/O Serial port sends and receives data one bit at a time. Serial communication devices are divided into: Data Communications Equipment (DCE),
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
Lecture Set 9 MCS-51 Serial Port.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
“Describe the overview of hardware interfacing and the serial communication interface. Describe the PIC18 connections to RS232. Explain the serial port.
Universal Asynchronous Receiver/Transmitter (UART)
Microprocessors 2 lesson Subjects lesson 7 Planning Interrupts Serial communication /USART Questions.
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire conductors)
Example. SBUF Register SCON Register(1) SCON Register(2)
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Universal Asynchronous Receiver/Transmitter (UART)
8051SERIAL PORT PROGRAMMING
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
8251 USART.
BASICS OF SERIAL COMMUNICATIONS BIRLA VISHWKARMA MAHAVIDYALAYA ELECTRONICS & TELECOMMUNICATION DEPARTMENT PRESENTING BY: ABHISHEK SINGH AMANDEEP.
Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of.
NARNARAYAN SHASTRI INSTITUTE OF TECHNOLOGY Prepared by: Wasu Ichcha kaur H Bhalani Nidhi M Dhakate Megha D MICROCONTROLLER.
Lecture # 14. RS – 232C Standard Standard for physical dimensions of the connectors. PC (DTE) Modem RS – 232C Cable Connected via serial port (DCE)
Chapter 4 UART Serial Port Programming 1. Serial vs. Parallel Data Transfer 2.
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Chapter 6 Serial Communications
Serial mode of data transfer
UART Serial Port Programming
RS-232 Communications.
INT. TO EMBEDDED SYSTEMS DEVELOPMENT
Homework Reading Continue mp1 Labs Tokheim, Section 13-6 Questions?
CS-401 Computer Architecture & Assembly Language Programming
Chapter 10 PIC18 Serial Port Programming in Assembly
SERIAL PORT PROGRAMMING
RS-232 Communications.
Serial Communication: RS-232 (IEEE Standard)
Local Asynchronous Communication (RS-232)
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 11-1.
USART Universal Synchronous Asynchronous Receiver Transmitter
UART Serial Port Programming
Asynchronous Serial Communications
UART Serial Port Programming
Serial Communication Interface: Using 8251
Serial Communication Interface
UART Protocol Chapter 11 Sepehr Naimi
Преглед Начин функционисања Имплементације
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
ADC and DAC Data Converter
UART PC16550 (Universal Asynchronous Receiver/Transmitter) By Derwyn Hollobaugh
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
Chapter 6 Transmission of Digital Data Interfaces and Modems
EUSART Serial Communication.
Source: Serial Port Source:
ADC and DAC Data Converter
8051SERIAL PORT PROGRAMMING
Figure Serial versus Parallel Data Transfer
PIC Serial Port Interfacing
PIC18 Interrupt Programming
AVR UART The UART, or Universal Asynchronous Receiver Transmitter, provides hardware support for a serial port on AVR processors Signaling is compatible.
Presentation transcript:

PIC Serial Port Interfacing “Describe the overview of hardware interfacing and the serial communication interface. Describe the PIC18 connections to RS232. Explain the serial port programming using assembly language” PIC Serial Port Interfacing

Objectives Explain serial communication protocol Describe data transfer rate and bps rate Interface the PIC18 with an RS232 connector Describe the main registers used by serial communication of the PIC18 Program the PIC18 serial port in Assembly

Introduction Computers transfer data in two ways: Parallel and Serial. Parallel: Eight or more data lines, few feet only, short time Serial: Single data line, long distance The PIC18 has serial communication capability built into it.

Basics of Serial Communication The byte of data must be converted to serial bits using a parallel-in-serial-out shift register Serial versus Parallel Data Transfer

Basics of Serial Communication (cont’d) The receiving end must be a serial-in-parallel-out shift register and pack them into a byte. Two methods of serial data communication: Synchronous and Asynchronous Transfers a block of data at a time Transfers a single byte at a time

Half-and Full-Duplex Transmission

Start and Stop Bits In the asynchronous method, each character is placed between start and stop bits (framing) Framing ASCII ‘A’ (41H) LSB MSB

Data Transfer Rate Rate of data transfer: bps (bits per second) Another widely used terminology for bps is baud rate For Asynchronous serial data communication, the baud rate is generally limited to 100,000bps

RS232 Standard Input-output voltage are not TTL compatible Standard for serial comm (COM port) 1: -3V to -25V; 0: +3V to +25V Reason: for long distance wired line Input-output voltage are not TTL compatible So, we need MAX232/233 for voltage converter. Commonly known as line drivers

RS232 Pins Connectors: Minimally, 3 wires: RxD, TxD, GND Could have 9-pin or 25-pin DB-9 9-Pin Connector DB-25 25-Pin Connector

RS232 Pins (cont’d) IBM PC DB-9 Signals Pin 1 – Data Carrier Detect (DCD) Pin 2 – Received Data (RxD) Pin 3 – Transmitted Data (TxD) Pin 4 – Data Terminal Ready (DTR) Pin 5 – Signal Ground (GND) Pin 6 – Data Set Ready (/DSR) Pin 7 – Request to Send (/RTS) Pin 8 – Clear to Send (/CTS) Pin 9 – Ring Indicator (RI) DB-9 9-Pin Connector Data in Data out

PIC18 Connection to RS232 Line driver (a) Inside MAX232 (b) its Connection to the PIC18

PIC18 Connection to RS232 (Cont’d) Line driver (a) Inside MAX233 (b) Its Connection to the PIC18

SPBRG Register and Baud Rate in the PIC18 The baud rate in the PIC18 is programmable The value loaded into the SPBRG decides the baud rate Depend on crystal frequency Baud Rate SPBRG (Hex Value) 38400 3 19200 7 9600 F 4800 20 2400 40 1200 81 *For XTAL = 10MHz only!

Baud Rate Formula Desired Baud Rate = Fosc/(64(X+1)) Example: If Fosc = 10 MHz X = (156250/Desired Baud Rate) - 1 Desired baud rate = 1200, Clock Frequency = 10MHz X = (156250/1200) – 1 X = 129.21 = 129 = 81H

TXREG Register 8-bit register used for serial communication in the PIC18 For a byte of data to be transferred via the Tx pin, it must be placed in the TXREG register

RCREG Register 8-bit register used for serial communication in the PIC18 When the bits are received serially via the Rx pin, the PIC18 deframes them by eliminating the START and STOP bit, making a byte out of data received and then placing in the RCREG register

TXSTA (Transmit Status and Control Register)

TXSTA (Transmit Status and Control Register) (Cont’d)

RCSTA (Receive Status and Control Register)

RCSTA (Receive Status and Control Register) (Cont’d)

PIR1 (Peripheral Interrupt Request Register 1)

Programming the PIC18 to Transfer Data Serially TXSTA register = 20H: Indicating asynchronous mode with 8-bit data frame, low baud rate and transmit enabled Set Tx pin an output Loaded SPBRG for baud rate Enabled the serial port (SPEN = 1) Character byte to transmit is write into TXREG Keep Monitor TXIF bit To transmit next character, go to step 5

Example ;Write a program for the PIC18 to transfer the letter 'G' serially ;at 9600 baud continuously. Assume XTAL = 10 MHz MOVLW B'00100000' MOVWF TXSTA MOVLW D'15' MOVWF SPBRG BCF TRISC, TX BSF RCSTA, SPEN OVER MOVLW A 'G' S1 BTFSS PIR1, TXIF BRA S1 MOVWF TXREG BRA OVER

Programming the PIC18 to Receive Data Serially RCSTA register = 90H: To enable the continuous receive in addition to the 8-bit data size option The TXSTA register = 00H: To choose the low baud rate option Loaded SPBRG for baud rate Set Rx pin an input Keep Monitor RCIF bit Move RCREG into a safe place To receive next character, go to step 5

Example ;Write a program for the PIC18 to receive data serially and ;put them on PORTB. Set the baud rate at 9600, 8-bit data ;and 1 stop bit MOVLW B‘10010000' MOVWF RCSTA MOVLW D'15' MOVWF SPBRG BSF TRISC, RX CLRF TRISB R1 BTFSS PIR1, RCIF BRA R1 MOVFF RCREG, PORTB

Transmit and Receive Please see program 10-1: Page 412

“Life is not so short but that there is always time enough for courtesy” – Quote by Ralph Waldo Emerson End of Chapter