English
Language : 

PIC18F1220_07 Datasheet, PDF (143/308 Pages) Microchip Technology – 18/20/28-Pin High-Performance, Enhanced Flash Microcontrollers with 10-bit A/D and nanoWatt Technology
PIC18F1220/1320
To set up an Asynchronous Transmission:
1. Initialize the SPBRGH:SPBRG registers for the
appropriate baud rate. Set or clear the BRGH
and BRG16 bits, as required, to achieve the
desired baud rate.
2. Enable the asynchronous serial port by clearing
bit SYNC and setting bit SPEN.
3. If interrupts are desired, set enable bit TXIE.
4. If 9-bit transmission is desired, set transmit bit
TX9. Can be used as address/data bit.
5. Enable the transmission by setting bit TXEN,
which will also set bit TXIF.
6. If 9-bit transmission is selected, the ninth bit
should be loaded in bit TX9D.
7. Load data to the TXREG register (starts
transmission).
If using interrupts, ensure that the GIE and PEIE bits in
the INTCON register (INTCON<7:6>) are set.
FIGURE 16-2:
EUSART TRANSMIT BLOCK DIAGRAM
TXIE
TXIF
MSb
(8)
Interrupt
TXEN Baud Rate CLK
Data Bus
TXREG Register
8
•••
TSR Register
BRG16
SPBRGH SPBRG
Baud Rate Generator
TX9
TX9D
LSb
RB1/AN5/TX/CK/INT1 pin
0
Pin Buffer
and Control
TRMT
SPEN
FIGURE 16-3:
Write to TXREG
BRG Output
(Shift Clock)
RB1/AN5/TX/
CK/INT1 (pin)
TXIF bit
(Transmit Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
ASYNCHRONOUS TRANSMISSION
Word 1
Start bit
bit 0
1 TCY
bit 1
Word 1
Word 1
Transmit Shift Reg
bit 7/8 Stop bit
© 2007 Microchip Technology Inc.
DS39605F-page 141