Professional Documents
Culture Documents
Chapter 3
Objectives
Upon completion of this chapter, you will be able to:
Explain serial communication protocol Describe the serial communication features of the PIC18 Program the PIC18 serial port in C
RS-232 Standards
Standard for serial comm (COM port)
1: -3V to -25V; 0: +3V to +25V Reason: for long distance wired line
Connectors
Minimally, 3 wires: RxD, TxD, GND Could have 9-pin or 25-pin
RS232 Connector
3 7 F 20 40 81
Example1
Write a C program to transfer the letter G serially at 9600, continuously. Use 8-bit data and 1 stop bit. Assume XTAL = 10MHz.
Example 1 (contd)
Example2
Write a C program to transfer the message YES serially at 9600, continuously. Use 8-bit data and 1 stop bit. Assume XTAL = 10MHz.
Example2 (contd)
Example 3
Write a C program to receive bytes of data serially and put them on PORTB. Set the baud rate at 9600, 8-bit data and 1 stop bit.
Example 3 (contd)
End of Chapter 3