Reading UART Tx FIFO level

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading UART Tx FIFO level

1,240 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Sun Dec 09 17:26:33 MST 2012
I'm writing a driver for a UART (on the 1227), so far it's working well but if I send too many bytes the FIFO fills and I lose characters. No problem I just write a buffer function that creates a software FIFO for the overflow.

So to implement that I need to test the hardware FIFO level, if it's full write to the software buffer, if not write directly to the hardware. But no matter what I do I get a value of 0 for LPC_UART0->FIFOLVL.

Here's the test code I'm currently using.

void serialWrite (uint8 b) {
    uint8 x = (LPC_UART0->FIFOLVL >> 8) & 0x0F;
    if (x < 15) {
        LPC_UART0->THR = 0x11;
        LPC_UART0->THR = 0x22;
        LPC_UART0->THR = 0x33;
        LPC_UART0->THR = LPC_UART0->FIFOLVL >> 8;  // !!!!!!!!!!!!!! this is always 0
        LPC_UART0->THR = 0x44;
    } else {
        fifoWrite (s->TxBuffer, b);
    }
}

(what's with no CODE tags on this forum?)

Because I think stopping the processor to use the debugger will allow the FIFO to empty and give me a bogus reading of FIFOLVL for testing I write three bytes into the FIFO then write the TXFIFOLVL bits from the register and finally another byte just to frame the level data.

I always get 0 for the LPC_UART0->FIFOLVL >> 8 byte when presumably it should be 4.

This should be simple right? Am I missing a secret handshake or something?
Labels (1)
0 Kudos
Reply
4 Replies

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tiagolone on Tue Jan 28 12:58:46 MST 2014
Hello,

There is some other way to know if the TX FIFO is full in lpc1227?
By the way, manual has not been updated yet.

Thank you
0 Kudos
Reply

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Daniel Widyanto on Tue Dec 18 23:14:18 MST 2012
The LPC12xx, along with LPC11xx and LPC13xx, does not implement FIFOLVL register. Only the LPC17xx above (LPC177x, LPC18xx, and LPC4xxx) that has this feature.

Thank you for brought this up. We'll update the LPC12xx User Manual to fix this issue.
0 Kudos
Reply

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Mon Dec 10 09:36:47 MST 2012
Thanks Dave, you mean you have to actually type the meta codes in? There's no buttons for quote, code, url etc.

And now it seems I can't edit my post. What kind of forum software is this?

Anyway, FWIW, responses on other forums indicate that this is a bug in the chip, reading FIFOLVL does not work.

0 Kudos
Reply

1,092 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dave on Sun Dec 09 23:20:12 MST 2012
Regarding CODE tags:

http://www.lpcware.com/content/project/lpcwarecom-help/highlighting-code

0 Kudos
Reply