You are on page 1of 25

PIC16F887

Lesson 12

EUSART
PIC16F887

EUSART
 The USART is one of the oldest serial
communication systems. The modern versions
of this system are upgraded and called
somewhat differently - EUSART.
 The Enhanced Universal Synchronous
Asynchronous Receiver
Transmitter (EUSART)module is a serial I/O
communication peripheral unit. It is also
known as Serial Communications
Interface(SCI).
PIC16F887

EUSART ON PIC16F887 FEATURES


Full-duplex asynchronous transmit
and receive
Programmable 8- or 9-bit wide
characters
Address detection in 9-bit mode
Input buffer overrun error detection
Half-duplex communication in
synchronous mode.
PIC16F887

EUSART ASYNCHRONOUS MODE


 The EUSART transmits and receives data
using a standard non-return-to-zero (NRZ)
format. As seen in figure below, this mode
doesn’t use clock signal, while the format of
data being transferred is very simple:
PIC16F887

EUSART ASYNCHRONOUS TRANSMITTER


PIC16F887

EUSART ASYNCHRONOUS RECEIVER


PIC16F887

ADDRESS DETECTION
PIC16F887

EUSART BAUD RATE GENERATOR


 The BRG timer consists of two 8-bit
registers making one 16-bit register.
 A number written to these two registers
determines the baud rate
PIC16F887

EUSART BAUD RATE GENERATOR


BITS
BRG / EUSART BAUD RATE
SYNC BRG1G BRGH MODE FORMULA

0 0 0 8-bit / asynchronous Fosc / [64 (n + 1)]

0 0 1 8-bit / asynchronous Fosc / [16 (n + 1)]

0 1 0 16-bit / asynchronous Fosc / [16 (n + 1)]

0 1 1 16-bit / asynchronous Fosc / [4 (n + 1)]

1 0 X 8-bit / asynchronous Fosc / [4 (n + 1)]


PIC16F887

EUSART BAUD RATE GENERATOR


PIC16F887

COMMUNICATE WITH PC SCHEMATIC


EUSART 2 MCU SCHEMATIC
PIC16F887
PIC16F887

EUSART MAIN COMMANDS

#USE rs232(baud=a,xmit=b,rcv=c)
Configure EUSART

a: baud rate
b: transmit pin
c: receive pin
Ex:

#USE rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)
PIC16F887

EUSART MAIN COMMANDS

value = kbhit()

This function returns TRUE if a


character has been received and is
waiting in the hardware buffer for
getc() to read.
PIC16F887

EUSART MAIN COMMANDS

putc (data)

This function sends a character over


the RS232 XMIT pin. A #USE RS232
must appear before this call to
determine the baud rate and pin
used.
PIC16F887

EUSART MAIN COMMANDS

puts (string)

Sends each character in the string


out the RS232 pin using putc()
PIC16F887

EUSART MAIN COMMANDS

value = getc()

This function waits for a character to


come in over the RS232 RCV pin and
returns the character. If you do not
want to hang forever waiting for an
incoming character use kbhit() to test
for a character available.
PIC16F887

EXAMPLE

Control MCU1 read temperature


from LM35 then send the read value
to MCU2 to display on it on LCD
PIC16F887

EXAMPLE
PIC16F887

MCU1 CODE
PIC16F887

MCU2 CODE
PIC16F887

MCU2 CODE
PIC16F887

MCU2 CODE
PIC16F887

Test the theory by simulink


PIC16F887

Lesson 12

EUSART

You might also like