Basic transmission is very simple, the byte to be transmit is placed in the Transmit Register (TXREG). This will cause the peripheral to transmit the byte. The TXREG register data is moved in to the shift register as soon as the shift register is empty, therefore it is possible to put another data byte into the TXREG before the previous one has completely been transmit. The TXIF flag that is low whilst data is in the TXREG and high when the TXREG is empty, therefore this flag can be monitored [or used to trigger an interrupt†] to determine when a new byte can be placed in the TXREG. To ensure that the TXREG is always empty before we put a byte into it, the TXIF status can be checked before placing data into the TXREG e.g.
Code The following code extract can be
used to transmit a byte to to the PC
†See using interrupts in Advanced Tutorial |