UART CTI ( Character time out indicator) Interrupt
2006-02-08 by swetha_araga
Yahoo Groups archive
Index last updated: 2026-04-28 23:31 UTC
Thread
2006-02-08 by swetha_araga
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
2006-02-08 by Robert Adsett
At 12:56 AM 2/8/06 +0000, swetha_araga wrote:
>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.
Two questions
- How big is the packet you are receiving?
- What is your receive threshold set to?
Robert
" 'Freedom' has no meaning of itself. There are always restrictions, be
they legal, genetic, or physical. If you don't believe me, try to chew a
radio signal. " -- Kelvin Throop, III
http://www.aeolusdevelopment.com/2006-02-08 by Kerem Or
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 > > > > > >
2006-02-08 by Kerem Or
What you see is natural behaviour of UART with FIFO. It is not related to MODBUS protocol. Obviously your RX FIFO level is more than 1 character. So, if the UART receives exactly the same no of chars determined by the RX FIFO setting, you would receive RDA interrupt. But what if the frame length is not multiple of RX FIFO level. In this case very last bytes of the incoming message will not fill the RX FIFO and you would never receive a RDA interrupt. Instead, the UART, in order to notify you that there are remaining bytes available in the RX FIFO, after receiving the last byte, waits sometime and generates a CTI interrupt. So what you need to do is to process this interrupt just like the RDA interrupt. Or if you dont want this behaviour, just set the FIFO level to 1. 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 > > > > > >
2006-02-08 by swetha_araga
Hi Robert, I set my FIFO trigger to 1 (bit 7:6 = 00 in U0FCR), and when I started seeing these CTIs, I tried setting it to 4 characters and 8 characters, but I still see only CTIs instead of RDA. Each character I am recieving is 10 bits in lenght and my baud rate is set to 19,200 right now. However I have tried using other baud rates too. I put a scope and verified that the characters are being sent at my baud rate settings. The whole write file is 2K bytes. I am able to read a file of that size without any problem... Also in the data sheet, there is a formula to calculate the exact CTI time and it uses a parameter called RCLK.. any idea what is this RCLK? Thanks, Swetha --- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@...> wrote: > > At 12:56 AM 2/8/06 +0000, swetha_araga wrote: > >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. > > Two questions > - How big is the packet you are receiving? > - What is your receive threshold set to? > > Robert > > " 'Freedom' has no meaning of itself. There are always restrictions, be > they legal, genetic, or physical. If you don't believe me, try to chew a
> radio signal. " -- Kelvin Throop, III > http://www.aeolusdevelopment.com/ >
2006-02-08 by swetha_araga
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 > > > > > > > > > > > > >
2006-02-08 by charlesgrenz
What does your routine look like?? regards, Charles --- In lpc2000@yahoogroups.com, "swetha_araga" <swetha_araga@...> wrote:
> > 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 > > > > > > > > > > > > > > > > > > > > >
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 > > > > > >
2006-02-08 by swetha_araga
After almost a week of debugging and looking for clues at all the places.. we found the bug we had. We were getting CTI and not RDA because our FIFO was getting set to trigger after 14 characters although we were trying to set it to 1, 4 or 8. The culprit ... a read modify write instruction we had. The uart FIFO register U0FCR is a write only register and after intializing, we were doing something like REG_UART1_BASE->regUFCR |= REG_UART_UFCR_FIFO_EN_MASK; which was a read modify write. UFCR and UIIR happen to share the same address (its a union) and so we were actually reading IIR and writing back to FCR. Boy... what a killer that was to find and what a lesson to remember for life - NEVER READ MODIFY WRITE a register which is write only. Thanks a lot to all members who gave me tips. Swetha