cancel
Showing results for 
Search instead for 
Did you mean: 

UART TX finished interrupt needed

d_steffen
Associate II
Posted on November 05, 2008 at 22:02

UART TX finished interrupt needed

12 REPLIES 12
andy_ry
Associate II
Posted on May 17, 2011 at 09:45

Hi! Try to use this:

while(UART_GetFlagStatus(UART0, UART_FLAG_Busy));

& RTFM!!!

BUSY: UART Busy

If this bit is set to 1, the UART is busy transmitting data. This bit remains set until the complete byte, including all the stop bits, has been sent from the shift register. This bit is set as soon as the transmit FIFO becomes non-empty (regardless of whether the UART is enabled or not).

UM0216 page 264

d_steffen
Associate II
Posted on May 17, 2011 at 09:45

I use uart interrupt and uart hardware fifo based transmitting and

receiving on the ST912FW44.

How can I get the information (an interrupt), if the

uart transmit (hw fifo used) finished, after the the last

byte is sended on the port pin output including the stop bit(s) ?

d_steffen
Associate II
Posted on May 17, 2011 at 09:45

Hi Andy,

I can't use busy waiting, I need to control how fast as possible

after (and before) trinsmitting a RX485 tx-enable pin in the interrupt handler.

Other controllers like atmel avr have an tx emtpy or

tx finished interrupt flag.

The busy flag can only polled outside the interrupt function in the application.

andy_ry
Associate II
Posted on May 17, 2011 at 09:45

Quote:

The busy flag can only polled outside the interrupt function in the application.

OK. In this case you should use buffer FIFO and fill data in it in process of a transmitting on interruption. The basic program will be carried out further.

if(UART_GetITStatus(UART0, UART_IT_Transmit) != RESET)

{

for(i = 0; (i < 8) && (TxCounter < NbrOfDataToTransfer); i++)

{

UART_SendData(UART0, TxBuffer[TxCounter++]);

}

if(TxCounter != NbrOfDataToTransfer)

{

/* Clear the UART0 transmit interrupt */

UART_ClearITPendingBit(UART0, UART_IT_Transmit);

}

else

{

/* Disable the UART Transmit interrupt */

UART_ITConfig(UART0, UART_IT_Transmit, DISABLE);

}

}

d_steffen
Associate II
Posted on May 17, 2011 at 09:45

I think you don't understand my question in

case of transmitting data with a RS485 communication.

1.) before you send any data from the uart you have

to switch on the tx enable line of the RS485 transceiver

2.) send out the data from the uart (hardware fifo, software fifo)

interrupt controlled

3.) switch off the tx enable line of the RS485 transceiver

immediately after the last stop bit from the last byte

of the transmitting frame ist sendet out from the uart

this all should be done in the uart ty interrupt handler,

the application only fills the software fifo and starts the

transmit interrupt

npivo
Associate II
Posted on May 17, 2011 at 09:45

Barricade wroute:

Quote:

1.) before you send any data from the uart you have

to switch on the tx enable line of the RS485 transceiver

...

3.) switch off the tx enable line of the RS485 transceiver

immediately after the last stop bit from the last byte

of the transmitting frame ist sendet out from the uart

this all should be done in the uart ty interrupt handler,

the application only fills the software fifo and starts the

transmit interrupt

All above could not be done inside UART tx interrupt handler!

At least you shoud switch on the tx enable line outside interrupt handler.

About p.3. I can not anderstand what for you want ''switch off the tx enable line ... immediately after the last stop bit from the last byte of the transmitting frame is sended out from the uart''? It is not nessasary. You may switch it off after you stop sending bytes into FIFO, even bytes steel staing in UART FIFO. Any way the bytes steel staing in FIFO will be sent out UART FIFO after that.

d_steffen
Associate II
Posted on May 17, 2011 at 09:45

read this for understanding RS485 communication

http://www.netrino.com/Articles/RS485Enable/index.php

akaiser9
Associate II
Posted on May 17, 2011 at 09:45

You could use a timer interrupt to poll the status. Not nice, but the UART macrocell does not appear to have any support beyond the status bit.

paulsmitton9
Associate III
Posted on May 17, 2011 at 09:45

Barricade: did you find a solution to your problem?

Or has anyone else found how to detect end of transmission without polling?

Cheers,

Paul :)