This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AN335x LSR_UART Register - Writing in Interrupt mode

Hi all, 

 In RTEMS a snippet code for the writing interrupt mode (ns16550_write_support_int ), looks like this:

  for (i = 0; i < out; ++i) {
    set( port, NS16550_TRANSMIT_BUFFER, buf [i]);
  }

Shouldn't we check, before writing to the register for the iterations after the first one, whether the character entered in the FIFO? (otherwise I think the 'for' loop could iterate so fast that the device had no time to process the character)

In such a case, something like

  for (i = 0; i < out; ++i) {
   /* Wait for transmitter holding register to be empty */
    do {
      status = get( port, NS16550_LINE_STATUS);
    } while ((status & SP_LSR_THOLD) == 0);  // Where SP_LSR_THOLD makes reference to TXFIFOE (from spruh73k.pdf  section 19.5.1.19: LSR_UART Register)
    set( port, NS16550_TRANSMIT_BUFFER, buf [i]);
  }


wouldn't be better?

Thanks in advance!