Mike - K8LH
Well-Known Member
Yes, that's right. TXIF = 1 indicates TXREG is empty and that it's ok to write a new character to TXREG. In fact that's why we use TXIF for interrupt driven serial I/O with circular buffers. The TXIF flag lets our ISR "pull" code know it can send another TX character from the circular buffer. The ISR "pull" code clears TXIE on "buffer empty" and the "push" routine in main will set TXIE when it adds a character to the circular buffer.Yes but TXIF is set anytime you set TXEN ...
My TXIF example does the same thing Jon. TXIF goes low when you stuff TXREG and goes high when TXREG is empty.... whereas TRMT is clear up until the transmit is complete. Thus you can load TXREG, then have your code go off and do other things, then poll the TRMT bit prior to transmitting the next byte. This way your code isn't tied to the UART during the transmit period.
Last edited: