Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!orion.oac.uci.edu!ucivax!jchoi From: jchoi@ics.uci.edu (John Choi) Newsgroups: comp.sys.mac.programmer Subject: Re: Need help programming SCC Message-ID: <27A8D317.5428@ics.uci.edu> Date: 1 Feb 91 02:31:50 GMT References: <1991Jan29.205455.26919@sol.UVic.CA> Reply-To: jchoi@ics.uci.edu (John Choi) Distribution: na Organization: UC Irvine Department of ICS Lines: 63 In article <1991Jan29.205455.26919@sol.UVic.CA> marykuca@sol.uvic.ca (Brent Marykuca) writes: > >We are trying to set up a fairly high-resolution timing device based >on the Time Manager's ability to run a task every millisecond. Our >task simply increments a global counter and it seems to give reasonable >accuracy. Our difficulty lies in trying to find an input device that .... >to wire up some sort of device to the serial port which will cause an >interrupt when one of two buttons is pressed, and then have our interrupt >handler read the clock for us. > >So, what I'm looking for is somebody who has done some low-level serial >port interrupt handler stuff with the SCC, or any tips at all about how >to approach this project. Can anybody help? > I have a similar set-up now using just the normal serial buffer functions in the Serial Driver Manager. I have a square pulse generated from a TTL chip go directly to pin 5 of the modem port with pin 4 as ground. The program sets up the modem port for regular serial communication at some arbitrary baud rate. When the data comes into the port it is stored in a data buffer. I clear the data buffer after each 'character' transmission and store the time away. My problem is that I can't seem to get Time Manager to work correctly. When I set up a loop to increment a global variable every 5 or 10 counts, each incremented vaule seems to correspond to 1.05 msec over a range of minutes. Do you just recalibrate to match real time or is there a real solution? I'm using THINK C 4.02 on a Mac II. If you don't have this problem, could you send me some of your timing routines. Thanks. Here is the Serial Port stuff - not really complete. timeSignals() { long len, config; short inPort; char inBuf[10]; int onLine = 1; OSErr anErr; EventRecord anEvent; anErr = RAMSDOpen(sPortA); inPort = -6; /* Modem port = -6 */ config = baud9600+data8+stop10+noParity; anErr = SerSetBuf(inPort, &inBuf, 10); anErr = SerReset(inPort, config); while(onLine) { anErr = SerGetBuf(inPort, &len); if(len){ anErr = FSRead(inPort, &len, &inBuff); timeNow = TickCount(); if(len > 1) DoErrText("Transfer Buffer Overflow"); } if(GetNextEvent(mDownMask,&anEvent)) onLine = 0; } RAMSDClose(sPortA); return; }