Home arrow Support arrow Forums

Luminary Micro Forums

<< Start < Prev 1 2 Next > End >>

femtotech

Expert Boarder
Click here to see the profile of this user

2008/09/19 11:35

UART Tx Interrupt

Hello,

I want to generate an interrupt after each transmitted byte. How can I achieve that?

Thanks!
Marco

login or register to reply

slandrum

Expert Boarder
Click here to see the profile of this user

2008/09/19 15:27

Re:UART Tx Interrupt

AFAIK, there's know way to do exactly what you want, which I find very frustrating. It's a major oversight on the interface that you can't get an immediate interrupt on data transmission or data receipt.

I have a similar requirement for a project I'm working on, and I've got a complicated piece of code that handles it taking advantage of the fact that my UARTs can only be used in half-duplex (they're connected to RS485 transceiver chips), and I make use of loop-back mode on the UART when I'm transmitting so I get back every byte I send.

login or register to reply

cb1

Platinum Boarder
Click here to see the profile of this user

2008/09/19 15:54

Re:UART Tx Interrupt

Seems to me that this would be more of a requirement on your Receive side - you likely "know" what byte you're sending.

Believe that I might have "worked around" similar to slandrum - over a year ago.

Describe better why you need this and perhaps we can assist...

login or register to reply

LMI scott

Junior Boarder
Click here to see the profile of this user

2008/09/19 16:07

Re:UART Tx Interrupt

One way that may help, but not get you exactly where you want to be, is to use the TX FIFO level interrupt. If you're streaming data, you could configure the transmit FIFO to generate an interrupt at 1/8 full (or less) which is 2 bytes, and then start the system by putting 3 bytes in the FIFO. After 1 byte is transmitted, an interrupt should be generated due to the FIFO level condition. Put another byte in the FIFO in the interrupt handler.

The downside is that if you don't have any outbound data for the transmit stream, the last two bytes are transmitted without interrupt. I picked the 1/8 FIFO level to minimize the missing interrupts.

Credit LMI Brian for the starting idea.

login or register to reply

slandrum

Expert Boarder
Click here to see the profile of this user

2008/09/19 23:57

Re:UART Tx Interrupt

I don't know about femtotech, but I need to know when my last byte transmits because I'm running half duplex through a part that has transmit/receive enable lines and need to turn my transmitter around immediately. Since I have to let the FIFO drain, I cannot make use any of the transmit FIFO interrupt.

There is no interrupt on TX complete, which I consider a major oversight.

As I said before I was able to work around the problem for my situation, but the solution is ugly and shouldn't have been necessary.

login or register to reply

femtotech

Expert Boarder
Click here to see the profile of this user

2008/09/20 03:18

Re:UART Tx Interrupt

I have to transmit DMX packets: they are composed of one byte at 90 kbps and up to 513 bytes at 250 kbps.

Furthermore I must control the tx enable line (it's a RS485 transceiver) so I need to know when the last byte is sent.

Of course I could polling the FIFO but in the meanwhile the CPU has to do a lot of other stuff. In other words I want to return to the main loop as soon as possible. I can't wait in a while loop until the whole transmission is completed.

A way could be to manage the transmission directly from the main loop: check the FIFO and transmit the next byte. I bet it would work, but it's not the best way, IMHO.

Bye
Marco

login or register to reply
<< Start < Prev 1 2 Next > End >>