10 years, 10 months ago.

Checking if Serial transmit FIFO empty

Hi.

I'm writing a 9 bit serial class, but I'm having troubles aroung the transmit FIFO.

The way I'm transmitting bytes, is by forcing parity bit high or low, distinguishing between addresses or data. This works as it should. But: When transmitting an address, with the pairty set high, and immediately after, transmitting a data byte, after forcing the parity to 0, will cause the data to look like an address.

I can come around this by waiting a calculated time, for the transmitter to transmit the data, but this is not good programming. I've tried a lot with different registers, reading the LSR register, checking for empty THRE, and so on.

Are there any chance this can be done by reading a register?

I've gone through the user manual of the LPC1768 several times now, now indication of empty transmit buffer anywhere. Help?

Thanks, Lerche

1 Answer

10 years, 10 months ago.

Isn't it bit 6 of the UARTn Line Status Register? I think that should tell it when both the fifo is empty and nothing is being shifted out anymore.

Accepted Answer

Hi Erik,

Thanks, but I have tried that.

Check if Serial transmit FIFO is empty

#include "mbed.h"

while(LPC_UART1->LSR & 0x40 != 0x40);    // Does nothing good for my program

Thanks, Lerche

posted by Christian Lerche 27 May 2013

     volatile int i;
     i = 0;
     while(i != 0x40){
          i = LPC_UART1->LSR & 0x40;
     }

Forgot to reset the variable i :-) Thanks

posted by Christian Lerche 30 May 2013