Wait4TXEmpty

Is it necessary to call Wait4TXEmpty() in ifi_utilities?

There is a slight delay between the time when you put a byte in the Tx buffer and when that data is actually sent over the Tx pin. TXREG is just a holding register for data you want to sent over the Tx pin. The chip will load the data from TXREG into the transmit shift register once the stop bit from the previous byte is sent over the Tx pin. Once data from TXREG is loaded into the shift register, TXIF is set, signaling TXREG is ready to receive more data.

If you try to write another byte into TXREG before TXIF is set, that byte that used to be there will never be transmitted.

So if you have enough of a delay between writes to TXREG, you can get away with not calling Wait4TXEmpty(), but it’s better to just call it.

Following on with Jay’s comments the real requirement is that the TXIF is set before writing the next character. If you are doing processing between characters it might be better to check TXIF before you send not wait for it to change after you send.