CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB CDC communication is failing on Win2K

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

USB CDC communication is failing on Win2K
PostPosted: Wed Jun 13, 2007 10:00 am     Reply with quote

Hi all,

I have a USB/CDC application based around the PIC18F2455. Essentially it just transfers bytes in both directions between a device on the USART and a PC via USB (for the purpose of this discussion, data is only sent towards the PC/host). I have found it to be very reliable under windows XP, but have problems with windows 2K pro (SP4). My implementation is based on the CCS examples for USB/CDC. I have tested it on several XP and 2K machines with consistent results.

As far as I can tell, when I call usb_cdc_putc(), a packet is sent to the host but the USB buffer used for transmission is never made free again. So nothing else is sent. This is of course only the case for win2K, XP is fine.

I tried running SnoopyPro on both XP and 2K. Both behaved the same during enumeration, but 2K is very different once data began to be sent to the PC. Under XP, a packet is sent from PIC to the PC typically containing one byte. A similar packet is sent back with zero bytes of data. This back and forth continues during transfer. Windows 2K receives the first packet with 1 byte but doesn't send a packet back. No further packets are exchanged.

In an effort to debug this, I ran the PIC under ICD2 on windows XP. What I found is that the application works correctly until I pause and resume execution (even for just a second). After this, no further communication occurs. Windows continues to regard the USB device as connected. I'm not sure if this behavior is related to my Win2K problem, but the result is similar.

Has anyone seen this kind of behavior? Any ideas as to where I should focus my attention? I have taken a look in the forums both here and at Microchip, and don't see much evidence of people having the problem...

/Thanks, Ross.
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Thu Jun 14, 2007 7:49 am     Reply with quote

Okay, so I have sorted out my problem...

The difference between Win2K and WinXP seems to be how the CDC driver acknowledges IN transactions when the virtual COM port is open or closed by an application. Under XP, the transaction is always acknowledged regardless of whether the COM port is open by the app. Win2K only acknowledges when an app has the port open.

The reason why communication didn't recover is that once the USB api stopped accepting new bytes, the serial port was overrun. I didn't include the 'errors' option in the use_rs232 directive... so once the error occurred, no more bytes were received from the serial port since the error condition was never cleared.

Doh!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group