Searching \ for '[PIC]: Data transfer from P16F877 to serial PC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=serial
Search entire site for: 'Data transfer from P16F877 to serial PC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Data transfer from P16F877 to serial PC'
2003\04\30@083133 by Rick Regan

picon face
{Quote hidden}

I understand the meanings of the flags but my question
still remains.  Can you give an example where
testing TRMT allows you to do something that just
testing TXIF exclusively couldn't do?

You can poll TXIF without using interrupts.
In the handshake situation you describe,
you could enable RCIF interrupts regardless of the
state of TSR, no?  Also, I can't see how knowing that
the data is sent out (TRMT=1) helps.  It certainly
doesn't tell you that the data was received at the
other end.


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2003\04\30@085212 by Dave Tweed

face
flavicon
face
Rick Regan <.....rdrdr2kKILLspamspam@spam@YAHOO.COM> wrote:
> I understand the meanings of the flags but my question still remains.
> Can you give an example where testing TRMT allows you to do something
> that just testing TXIF exclusively couldn't do?

If you're using a physical interface that requires a separate
transmit-enable signal (like RS-485), you need to know when the last byte
has been completely transmitted before you turn off the driver.

-- Dave Tweed

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body

2003\04\30@094831 by Olin Lathrop

face picon face
> I understand the meanings of the flags but my question
> still remains.  Can you give an example where
> testing TRMT allows you to do something that just
> testing TXIF exclusively couldn't do?

The two flags have different meanings and purposes.  Most of the time you
want to know when it's OK to write another byte to TXREG.  You check TXIF
for this, or use the TXIF interrupt.  See the HOS_UART.ASPIC module at
http://www.embedinc.com/pic/hos.htm for an example UART handler that uses
the TXIF interrupt.  The application calls UART_PUT, which writes the byte
to a FIFO.  It doesn't get written to the UART until the UART is ready for
it.  The TXIF interrupt is used to transfer one more byte from the FIFO to
the UART.

The TRMT flag tells you that the whole byte has actually been sent on the
wire.  Most of the time you don't care, but it can be important to know if
the wire is being shared.  I've only used the TRMT flag twice that I can
remember.  Once was when the UART was connected to a RS-485 bus.  The
firmware had to know when the last packet byte was actually sent before
reversing the bus driver hardware from transmit to receive.  The other
time was making sure the last byte was physically sent before powering
down.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body

2003\04\30@095735 by Jinx

face picon face
> I understand the meanings of the flags but my question
> still remains.  Can you give an example where
> testing TRMT allows you to do something that just
> testing TXIF exclusively couldn't do?

In addition to the examples put forward by Dave Tweed and
Martin Buehler, there is the time delay. Loading TXREG with
data takes a small number of cycles. One cycle to move TXREG
to TSR. But the data could take hundreds of microseconds to
transmit. A 9600 baud byte is around a millisecond for example

> You can poll TXIF without using interrupts.

Of course. I'm not saying anything is compulsory, just that testing
one or the other may be efficient/necessary/elegant in some
situations. The UART itself is fairly simple, but you could write any
number of software structures to use it and so many variables it
would be easy to concoct an example

> Also, I can't see how knowing that the data is sent out (TRMT=1)
> helps.

The obvious answer is that in some cases you can then direct the
s/w or h/w to then move on to doing something else

> It certainly doesn't tell you that the data was received at the other end

No, it doesn't. Verification would be a whole new ball game, but
doesn't necessarily alter the way that the UART is used

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

2003\04\30@112809 by John Temples

flavicon
face
On Wed, 30 Apr 2003, Olin Lathrop wrote:

> The TRMT flag tells you that the whole byte has actually been sent on the
> wire.

No, it does not.  It tells you that the transmit shift register is
empty.  It does not mean the UART has finished transmitting it on the
wire.

> Most of the time you don't care, but it can be important to know if
> the wire is being shared.  I've only used the TRMT flag twice that I can
> remember.  Once was when the UART was connected to a RS-485 bus.  The
> firmware had to know when the last packet byte was actually sent before
> reversing the bus driver hardware from transmit to receive.

In both of these situations, you might have triggered framing errors
at the receiver by relying on TRMT.

--
John W. Temples, III

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\04\30@155123 by Bob Ammerman

picon face
Check TXIF if you are sending more bytes. This way a new byte will be queued
before the last one has been completely sent out.

Check TRMT if you are waiting for the transmitter to be done (for example
before turning off a line driver).

Bob Ammerman
RAm Systems

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...