Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Re: UART CTI ( Character time out indicator) Interrupt

2006-02-08 by Kerem Or

Hi Swetha,

Check the below isr and init code which may ring a bell in your case. It 
runs on LPC2131 without any odd behaviour.

void TUart::isr(void)
{
  unsigned int temp,stat;

  switch(U0IIR & 0x0f) {                                    // check source 
of interrupt
  case UINT_TXRDY :                                         // tx ready is 
by txfifo empty
    temp=U_TX_FIFO_DEPTH - U_TX_FIFO_LVL;                   // at least 
depth-level bytes empty

    if(txlen < temp)                                        // if nof bytes 
left < empty spaces
      temp=txlen;                                           // transmit 
remaining bytes in txbuffer

    txlen-=temp;                                            // reduce tx 
length

    while(temp--)                                           // fill txfifo
      U0THR=txbuf[txptr++];

    if(txlen==0) {                                          // no more bytes 
to be transmitted
      U0IER=0;                                              // disable tx 
int, disable rx int
      eoftx=true;                                           // wait till tx 
shift reg becomes empty prior to disabling RS485 xmitter
    }

    break;
  case UINT_RXRDY :                                         // received data 
ready is by rx trigger level
  case UINT_RXTOUT :                                        // rx timeout is 
by 4 char + 12 bit delay timer
    while((stat=U0LSR) & U_RXRDY) {                         // rxfifo not 
empty
      temp=U0RBR;                                           // read received 
byte off the rxfifo
      if(!txactive) {                                       // check if tx 
idle
        if(!(stat & U_RXERR))                               // process rx 
data only if no rx error
          rxisr_handler(temp);
      }
    }
    break;

  case UINT_LSR :                                           // rx line 
status [rx overrun,rx parity,rx framing,rx break]
    temp=U0LSR;                                             // read LSR 
clears the above flags
    break;
  }
}

void TUart::open(void)
{
  unsigned int divisor;

  uart=this;

  __setio(PCONP,0x08);                                      // enable uart0 
power and mask rsvd bits
  PINSEL0_bit.P0_0=1;                                       // P0.0 = TXD0
  PINSEL0_bit.P0_1=1;                                       // P0.1 = RXD0

  divisor=U_BD2VAL(9600);                                   // calculate 
baud divisor

  U0LCR=U_DLAB_ENABLE;
  U0DLL=lob(divisor);                                       // baud rate low 
byte
  U0DLM=hib(divisor);                                       // baud rate 
high byte
  U0LCR=U_DLAB_DISABLE;

  U0LCR=U_L_8 | U_STOP_1_BIT | U_PARITY_NONE;
  U0FCR=U_RXF_14|U_TXFIFO_RST|U_RXFIFO_RST|U_FIFO_EN;       // enb/rst 
fifos,rxlvl=14
  U0IER=U_IE_RHR;                                           // rxd int 
enable, txd int disable
}


Kerem

----- Original Message ----- 
From: "swetha_araga" <swetha_araga@...>
To: <lpc2000@yahoogroups.com>
Sent: Wednesday, February 08, 2006 6:23 PM
Subject: [lpc2000] Re: UART CTI ( Character time out indicator) Interrupt


> Hi Kerem,
> I have the FIFO enabled and I was using RX trigger level of 0 (i.e 1
> character). With this setting, I was pretty sure I will get a RDA
> everytime I recieve a character, but I dont. When I started seeing
> these CTIs, I tried increasing the trigger to 4 and even 8 and I
> still see only CTIs, which is not too puzzling. But with 1 character
> trigger I am really baffled as to why I see CTI interrupts.
>
> Thanks,
> Swetha
>
> --- In lpc2000@yahoogroups.com, "Kerem Or" <k.or@...> wrote:
>>
>> What is your rx fifo settings ?
>>
>> Kerem
>>
>> ----- Original Message ----- 
>> From: "swetha_araga" <swetha_araga@...>
>> To: <lpc2000@yahoogroups.com>
>> Sent: Wednesday, February 08, 2006 2:56 AM
>> Subject: [lpc2000] UART CTI ( Character time out indicator)
> Interrupt
>>
>>
>> > Hi,
>> > I am using MODBUS serial communication through UART on LPC2138.
> My
>> > transmission works fine, but for some reason during reception, I
> never
>> > seem to get the RDA interrupt and always get the CTI instead. I
> have
>> > enabled only the RBR interrupt and disabled the THRE and RX line
>> > status interrupts.
>> >
>> > Anyone has faced any similar problems? Suggestions and tips are
> welcome
>> >
>> > Thanks,
>> > Swetha
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.