Setting uart FIFO level problem on LPC236x

Started by alin June 1, 2010
Hello,

I'm having some difficulties in setting the uart FIFO level lower than 14 characters. Whatever i try to write in the FCR register, the IIR register will always read 0xC1 (which means FIFO level 14) and my interrupt routine (triggered by RDA bit) will not trigger until i send 14 characters to the uart. The register gets set to this value regardless of what I actually write in it. This happens on all 4 uarts in the chip.

The chip has revision B silicon. I also tried it on a LPC2368 and LPC2138. I also tried various example routines from IAR and KEIL but the same result.

Is there something special that i should consider when i try to set this register? I saw in some 16c550 discrete IC uarts that you should always set bit0 when writing to the FCR register but I also tried this and it's the same thing.

I know i could use the CTI interrupt but i want to trigger an event if there's a pause between characters received equal to 2 byte times and the CTI interrupt only triggers after 3.5-4.5 byte times.

I'm using a J-link for debugging. Can anyone certify that you can really set the FIFO level to something other than FIFO level 14.

Thank you,
Alin

An Engineer's Guide to the LPC2100 Series

--- In l..., "alin" wrote:
>
> I'm having some difficulties in setting the uart FIFO level lower than 14 characters. Whatever i try to write in the FCR register, the IIR register will always read 0xC1 (which means FIFO level 14) and my interrupt routine (triggered by RDA bit) will not trigger until i send 14 characters to the uart. The register gets set to this value regardless of what I actually write in it. This happens on all 4 uarts in the chip.
>

My understanding of the user manual is that bits 6 and 7 of the IIR register are both equivalent to the FIFO enable bit FCR[0] (i.e. bit 0). They are not equal to FCR[7:6]. Hence, the fact that FCR is 0xC1 is not telling you anything about the FIFO level value.

Regards,
Chris Burrows

CFB Software
Astrobe: LPC2xxx Oberon-07 Development System
http://www.astrobe.com

Yes, you're right. Thank you for the eye-opener, I probably was too tired then. I was focused solely on seieng that value change that i didn't try read properly the manual.
But there was also another problem. I was trying to write the register through some fancy defines and OR-ing and the compiler (IAR) probably didn't write the register properly.

So basically this didn't work
uartcfg->regptr->IIFCR |= UART_FIFO_TRG_LEV0;

or this
uartcfg->regptr->IIFCR |= (UART_FIFO_TRG_LEV0 | UART_FIFO_EN);

but this does work
uartcfg->regptr->IIFCR = 0x01;

Go figure ...

Thanks again,
Alin

--- In l..., "cfbsoftware1" wrote:
>
> --- In l..., "alin" wrote:
> >
> > I'm having some difficulties in setting the uart FIFO level lower than 14 characters. Whatever i try to write in the FCR register, the IIR register will always read 0xC1 (which means FIFO level 14) and my interrupt routine (triggered by RDA bit) will not trigger until i send 14 characters to the uart. The register gets set to this value regardless of what I actually write in it. This happens on all 4 uarts in the chip.
> > My understanding of the user manual is that bits 6 and 7 of the IIR register are both equivalent to the FIFO enable bit FCR[0] (i.e. bit 0). They are not equal to FCR[7:6]. Hence, the fact that FCR is 0xC1 is not telling you anything about the FIFO level value.
>
> Regards,
> Chris Burrows
>
> CFB Software
> Astrobe: LPC2xxx Oberon-07 Development System
> http://www.astrobe.com
>

--- In l..., "alin" wrote:
>
> So basically this didn't work
> uartcfg->regptr->IIFCR |= UART_FIFO_TRG_LEV0;
>
> or this
> uartcfg->regptr->IIFCR |= (UART_FIFO_TRG_LEV0 | UART_FIFO_EN);
>
> but this does work
> uartcfg->regptr->IIFCR = 0x01;
>

IICFR is write-only isn't it? If so you should not be using a read-write (i.e. |= ) operation on it. What effect that might have I do not know.

Regards,
Chris Burrows

CFB Software
Astrobe: LPC2000 Oberon-07 Development System
http://www.astrobe.com

> IICFR is write-only isn't it? If so you should not be using a read-write (i.e. |= ) operation on it. What effect that might have I do not know.
Correct, FCR is write-only.
The effect will be to read the IIR register (same address, but read-only), then OR that value with your data, and write the result to FCR. Not what you want.