Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 11


Compilers often provide library functions that simplify accessing the port hard-
ware.

4  
 '#+


The PIC18F4520 has an 8-bit data bus, 32 kilobytes (KB) of flash memory for
program storage, and 1.5 KB of RAM and 256 bytes of EEPROM for data stor-
age. The power supply can range from +4.2V to +5.5V. The PIC18LF4520
variant can use a power supply as low as +2V.
For serial communications, the chip contains an enhanced USART (EUSART)
that supports asynchronous and synchronous serial communications. Other
on-chip functions include four timers, a 10-bit analog-to-digital converter with
up to 13 channels, an analog comparator, and two modules that can perform
capture, compare, and pulse-width-modulation (PWM) functions. The
40/44-pin versions also have an 8-bit parallel port. Most of the chips’ I/O pins
have assigned functions, such as serial-port input and output, but the pins can
have other uses if firmware isn’t using the assigned functions.
Other chips in the PIC18F4520 series have different combinations of functions
and package options. The data sheet for the series has complete documentation
for the chips.

1
0  

. 1


The PIC18F4520’s EUSART supports using either an asynchronous or syn-
chronous interface but not both at the same time. However, the PIC18F4520
has an additional synchronous serial port module that supports synchronous
communications. The enhanced features of the EUSART include automatic
bit-rate detecting and a 16-bit register for finer control of bit rates. Other PIC
microcontrollers have similar USARTs, though not every variant has the
enhanced features of the EUSART.
The PIC18F4520 dedicates two port bits for the asynchronous port. Port C, bit
6 is the data output (TX), and Port C, bit 7 is the data input (RX). Hardware
flow control can use any spare port pins. The pins can interface directly to most
TTL and CMOS logic chips, including the TTL/CMOS interfaces on many
RS-232 and RS-485 converter chips.
Free download pdf