Information
2002 Microchip Technology Inc. DS80058H-page 9
PIC18CXX2
6. Module: USART
The operation of the USART Transmit Interrupt
flag bit TXIF (PIR1<4>) is clarified as follows:
TXIF is not cleared immediately upon loading data
into the transmit buffer TXREG. The flag bit
becomes valid in the second instruction cycle fol-
lowing the load instruction (see Example 1). Poll-
ing TXIF immediately following a load of TXREG
will give invalid results (Example 2).
This clarification applies to all USART transmis-
sion modes (master or slave, synchronous or
asynchronous, 8-bit or 9-bit).
EXAMPLE 1: CORRECTLY POLLING
THE TXIF BIT
EXAMPLE 2: POLLING THE TXIF BIT
IMMEDIATELY AFTER
LOADING THE TRANSMIT
BUFFER
movwf TXREG ;load the register
nop :first instruction--
;just a placeholder, it
;could be any instruction
btfss PIR1,TXIF ;second instruction--
;now TXIF is valid
movwf TXREG ;load the register
btfss PIR1,TXIF ;first instruction--
;reading TXIF now will
;give invalid results