Hi Sam, Unfortunately I think your probably attacking this from the wrong way if you're running this under Windows 95/99/ME/NT/2000 (Win32). Code the directly access registers and interrupts is doomed to fail. Basically Windows protects direct access to interrupts and IO ports so that multiple programs will play together nicely. You need to use the windows provided serial functions. Look at the SetCommState() function to setup the serial port, CreateFile() to open a serial port (Name is "COM1" or something like that from memory). VC++ should have help on these.. if not look on http://msdn.microsoft.com. You then use WriteFile() and ReadFile() to send and read data, and you can configure "Event" (kind of like interrupts) using SetCommMask(). You may be able to find examples in the MSDN site for all this stuff. The event driven stuff is tricky to get your head around in windows if you haven't played with it before. If you don't need to know EXACTLY when a new character arrives, or the state of the CTS/DSR lines etc change, then it is not too difficult. You can open the serial port with CreateFile("COM1", .....), use GetCommState() to retrieve the current settings (speed etc) and SetCommState() to alter them to be what you need, then you can sit in a loop using ReadFile() to read incoming data. If you need to send data to the device, use WriteFile(). Then CloseHandle() when your finished. Let me know if I can be more help. Good luck. Ash. > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of sam woolf > Sent: Tuesday, 10 July 2001 10:56 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [OT]:serial port communication > > > I'm having a bit of a nightmare doing serial port > communication between a computer and a 16f84. The pic is > sending data at 19200 baud to the computer. I have been using > a c program based on craig peacock's at > www.beyondlogic.org/serial/termpoll.c . But unfortunately I > am losing significant amounts of data. I think this is > because the code needs to be interrupt driven but I can't get > the interrupt driven version > (www.beyondlogic.org/serial/buff1024.c )to work... My > compiler does not like the weird pointer-to-function or > whatever it is stuff going on with the interrupt function and > I cant get my head around what its supposed to be doing > either... I'm using microsoft visual c++ 5.0 and have already > had to make several adjustments such as changing all the > inportb()s to _inp()s... does anyone know what I need to do > to make this work, or does anyone have any simple to > understand and working microsoft visual c++ 5.0 code for > doing interrupt driven serial comms?? I know this is slightly > off topic but I am at my wits end!! > SW > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu