Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!keele!csd35 From: csd35@seq1.keele.ac.uk (Jonathan Knight) Newsgroups: comp.os.msdos.programmer Subject: Getting data from asynchronous serial ports Message-ID: <768@keele.keele.ac.uk> Date: 20 Dec 90 10:37:23 GMT Organization: University of Keele, England Lines: 44 Hi, I'm having trouble reading data from a serial port if the data arrives at the maximum chars per second the baud rate allows. If the data arrives interspaced with pauses then it arrives perfectly. Here is a short piece of code I've been using main() { int i; for (i=0; i<100; ++i) printf("%d\t", inp(0x338)); } The idea is to repeatedly read the port and just see what turns up. I have more complicated code that runs under interrupt and tests all sorts of bits of the status register and things, but this was enough to see what was happening. If I connect a terminal to the port and type [A (the codes the up arrow generates) then I get to see 27 91 65 (lots of times for each). If I hit the up arrow key I get 27 171 255. Now if I program a soft key with the same sequence I can adjust the rate that the data is sent to the computer. If I run at a baud rate of 4800 and set the function keys to generate at 150cps then all goes fine. If I let them run at 480cps (max rate) then the 27 171 255 is seen again. Note I get the same sequence whatever baud rate I run at (even 300), but it always works perfectly if I deliberately set the cps to less than max for the baud rate. If anyone can shed any light then I'd be grateful. ------------- I have lost the book I was using which dealt with the serial I/O stuff. If anyone can type in a quick summery of the UART's ports then I'd be forever grateful. If anyone can summerise the PIC's commands, that would help too. -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.