Chapter 10 PIC18 Serial Port Programming in Assembly

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.
Serial I/O - Programmable Communication Interface
Starting with serial Chapter Ten 10.1, 10.2,
Eng. Husam Alzaq The Islamic Uni. Of Gaza
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 9-1.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
EEE305 Microcontroller Systems Lecture 7: Embedded C using PIC microcontrollers Serial i/o with the XC8 Teaching resources are at
Smart-grid Interface with Photovoltaic Installation – Phase 2 PP-01 Team members: Matt Koresh Ivan Mills Matt Martin Advisor: Dr. Aliprantis.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
Serial Communication ETEC 6416.
Today’s Lecture List the Timers of PIC18 and their associated registers Describe the various modes of the PIC18 timers Program the PIC18 timers in Assembly.
USART interrupt.
The 8051 Microcontroller and Embedded Systems
Digilent System Board Capabilities Serial Port (RS-232) Parallel Port 1 Pushbutton Hint: Good for a reset button Connected to a clock input. See Digilent.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
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.
“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)
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.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Aum Amriteswaryai Namah:. PIN DIAGRAM WW hen two processors are to communicate, more often the communication is organized in a bit serial fashion The.
PIC Microcontroller and Embedded Systems 1/e By Muhammad Mazidi, Rolin McKinlay, and Danny Causey © 2008 Pearson Education, Inc. Pearson Prentice Hall.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
8251 USART.
Criteria for choosing a microcontroller A microcontroller must meet the task at hand efficiency and cost effectively. Speed. What is highest speed of.
TIMERS.
Chapter 9 PIC18 Timer Programming in Assembly
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.
Serial mode of data transfer
RS-232 Communications.
INT. TO EMBEDDED SYSTEMS DEVELOPMENT
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
Input/Output and Communication
Chapter 10 Input/Output Organization
Diagram of microprocessor interface with IO devices
Serial I/O and Data Communication.
SERIAL PORT PROGRAMMING
Interrupts, Counter and Timers
ATMEGA 32 CONNECTIONS TO RS232; UDR AND UCSR REGISTERS
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
E3165 DIGITAL ELECTRONIC SYSTEM
Atmega32 Serial Programming Basics
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.
Computer Organization and Design
Introduction to Microprocessors and Microcontrollers
USART Universal Synchronous Asynchronous Receiver Transmitter
UART Serial Port Programming
UART Serial Port Programming
Serial Communication Interface: Using 8251
Serial Communication Interface
UART Protocol Chapter 11 Sepehr Naimi
COMP3221: Microprocessors and Embedded Systems
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
ADC and DAC Data Converter
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
PIC18 Interrupt Programming
EUSART Serial Communication.
Prof Afonso Ferreira Miguel
PIC Serial Port Interfacing
ADC and DAC Data Converter
8051SERIAL PORT PROGRAMMING
Figure Serial versus Parallel Data Transfer
PIC Serial Port Interfacing
PIC18 Interrupt Programming
Presentation transcript:

Chapter 10 PIC18 Serial Port Programming in Assembly

Objective 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.

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

PIC18 Serial Port Programming in Assembly USART has both Synchronous Asynchronous 6 registers SPBRG TXREG RCREG TXSTA RCSTA PIR1 Rx Port Tx Port

SPBRG Register and Baud Rate in the PIC18 SPBRG (Hex Value) 38400 3 19200 7 9600 F 4800 20 2400 40 1200 81 The baud rate in is programmable loaded into the SPBRG decides the baud rate Depend on crystal frequency BR = F Fosc 4*16*(X+1)( Baud rate Formula If Fosc = 10MHz X = (156250/Desired Baud Rate) - 1

TXREG Register RCREG 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 first. The moment a byte is written into TXREG, it is fetched into a non-accessible register TSR MOVFF PORTB, TXREG The frame contains 10 bits 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 it in the RCREG register MOVFF RCREG, PORTB

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 (RC6) Loaded SPBRG for baud rate Enabled the serial port (SPEN = 1 in RCSTA) The character byte to transmit must be written 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'; 9600 bps MOVWF SPBRG BCF TRISC, TX BSF RCSTA, SPEN OVER MOVLW A'G' S1 BTFSS PIR1, TXIF BRA S1 MOVWF TXREG BRA OVER

TXSTA: Transmit Status and Control Register

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

Increasing the Baud Rate Faster Crystal May not be able to change crystal TXSTA.BRGH bit Normally used low Can be set high Quadruples rate when set high

Baud Rate Error Calculation ??? Errors in the baud rate? Yep! Caused by using integer division in rate generator

Simplified USART Transmit Block Diagram