--- In lpc2000@yahoogroups.com, "Dave" <dgsomerton@w...> wrote: > --- In lpc2000@yahoogroups.com, "vajper0" <ph@w...> wrote: > > I'm writing a driver for UART1 on a LPC2138. So far most things seems > > to work (considering the crappy hardware capabilities). My current > > problem is that I loose interrupts when receiving data. > > > > I run the UART in 115200bps and my ISR takes care of all IRQs except > > the modem status ones that are not enabled. If I send a block of a > > couple of hundreds characters, sometimes one RDA IRQ is lost. I know > > this because the missing data always are the size of the Rx trigger > level. > > > > The ISR reads the U1IIR once in the beginning, compares the register > > data to the different IRQ types in priority order. The first matching > > type is handled (and the IRQ resetted), the U1IIR is then read again > > and so on. When no more pending IRQs, the ISR is exited. When a > > > > Am I missing something essential? > > Hello, > > I use a 2132, but the initial development was done on a 2138 > evaluation board from keil, the M something 2130. > I have interrupt comm at 115200, and do not seem to miss any. > Do you enable the FIFO? If so, do you empty the FIFO each RX data > IRQ? If so, do you also enable the TIMEOUT IRQ and collect the > remainder data (less than one FIFO). > In my application, I set the FIFO to 14 bytes (the maximum). > In the IRQ I loop until the IIR reads no pending. > As this application also uses rs485 half duplex, I thought the TEMPT > (transmitter empty) bit could generate an interrupt, and the > direction could be dropped changed back to listen. But it does not, so > on tx complete, a flag is set, and the timer IRQ looks for the TEMPT > bit and does it's thing. > A similar thing to detect when the line is available, each RX IRQ, > set the 'receiving' flag, and mark the time of the reception. When 'a > certain amount of time has passed without receiving characters' could > be a clear channel. > A slight modification of this was, when the TIMEOUT interrupt > occurs, this indicates clear channel of at least '3.5' character > times, and this can be used. Well infact it is used, but the other > method also remains, as what if the last block of received data is > exactly one FIFO long, then no TIMEOUT IRQ will come, and so the timer > method of clear channel detection is used. This is controlled by a > single flag and a time of last reception value. > > Anything else? > Being at home now, the code is not available, but I could send > something tomorrow when I get to work. But really, it's not that > difficult. > > Dave Firstly I figured out one of my issues. I was trying to setup a HDLC- ish style link since I need to send packets of data. I was using the 7E for the flag and idle in the link as specified. Figured out if you send a constant stream of these its very easy for the UART to mis- interpret the start bit and receive F9 characters instead of 7E. I changed the flag character and this changed some of my issues but not all. With that said I still have all the other issues related to interrupts and errors. What I do is check the U1IIR and then go to the proper subroutine depending on what interrupt it specifies. In the transmit routine I send out the buffered data or idle characters till the TX FIFO is full. In the receive routine I read all the characters till the RDA bit goes low in the U1LSR register therefor emptying the RX FIFO. I suspect I do not use the character timeout much since I am sending idle characters to ensure the link is always active so I can tell if the link is broken as soon as it occurs. Once these subroutines are done I go back to the main interrupt service routine and check to see if another serial interrupt is pending and process it also. I also check for errors in U1LSR as I am reading data and am clearing them by reading and discarding the data. I also was flushing the RX FIFO but commented that part out for the moment incase that was the cause of some of my issues. Any info you can give me would be great. Thank you. Pascal
Message
Re: Lost UART1 IRQ?
2005-07-19 by genie_23432
Attachments
- No local attachments were found for this message.