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 support@ccsinfo.com

USB Problem with CCS functions on PIC18F4550

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



Joined: 06 Feb 2008
Posts: 17

View user's profile Send private message

USB Problem with CCS functions on PIC18F4550
PostPosted: Wed Feb 06, 2008 2:36 pm     Reply with quote

To all who will actually read this (I know its long, sorry) thanks in advance!

We needed to make a small temperature controller that could interface to a PC over USB so we began with the CCS example ex_usb_serial.c USB CDC API virtual UART, and were successful in communicating characters back and forth using HyperTerminal on the PC and the functions usb_cdc_putc(), usb_cdc_kbhit() and usb_cdc_getc() in our Controller.

We then 'added' our application to the existing CCS files (usb_cdc.h, pic18_usb.h, usb.h, usb_desc_cdc.h, etc.). At the PC end, we created a Visual Basic application to use the appropriate serial port to communicate with our Controller.

Then, since the UART/HyperTerminal example was just a character-for-character echo, we built a simple message protocol with a unique 'Start of Message' character so that short control/status messages (7 bytes ea) could be exchanged between the PC and our Controller. The PC, as the initiator, sends a request or command and the Controller sends a response message.

Everything seems to work well except for an intermittent bug:

The PC makes the 'connect' sound when we plug in our USB controller (enumerates? we have no USB 'snooper' or USB test facilities) and the PC can then be commanded to continuously exchange messages with our Controller.
The exact sequence is as follows:
The PC application shows a USB error

But, after a variable time, our Controller 'hangs' and the Controller will not respond to USB comms or user key input.
If I do not unplug the USB connection, after another variable time, our Controller resets. But USB comm does not resume automatically; we must unplug the USB and restart our VB application at the PC.

If I unplug the USB cable from the PC USB port as soon as the controller 'hangs' the controller still will not respond to user key input

Most of the time when I plug it back in to the USB port it will again begin to respond to user key input even though the PC application is disconnected (not trying to communicate)

When I click connect on the PC application, normal comms resumes.

Debugging: a faster rate of message exchanges with the PC seems to make the problem occur sooner, but it is still a variariable time from startup; communication can run OK for 30 seconds to several minutes (hundreds or thousands of messages) before the 'hang'. In looking to isolate the problem, The 'hang' seems to happen while outputting the USB message using usb_cdc_putc(); we have tried using usb_cdc_putready() before each usb_cdc_putc() and have also called usb_task() between each of the character outputs, but the 'hang' persists.

The restart of our Controller after the second delay is also something of a puzzle: it seems to be too long of a time for a Watchdog reset, but this possibility cannot be ruled out as yet. Also, we have been able to recover from the 'hang' before our Controller resets by: stopping the VB app, unplugging, then replugging the USB connector, restarting the VB app, and restarting USB communications; it is not clear whether this points to the PC end or or Controller end of the USB cable as the 'problem end.'

CCS forum users have posted some USB problems that seem similar, or could be related to what we are experiencing, but we have not as yet found anything to try that eliminated our problem.
_________________
Thanks,

NuWaveDC
Tre



Joined: 03 Jun 2005
Posts: 21

View user's profile Send private message

PostPosted: Wed Feb 06, 2008 4:44 pm     Reply with quote

I have exactly the same problem, please look at my thread just a few posts before yours. Maybe we can compare notes and get to the bottom of this, I suspect it is a buffer problem somewhere with CDC.

Do you have any interrupts running?
Tre



Joined: 03 Jun 2005
Posts: 21

View user's profile Send private message

PostPosted: Wed Feb 06, 2008 4:45 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=33582 for reference
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 07, 2008 2:01 pm     Reply with quote

EMail CCS tech support of this issue. They have new drivers that may work better for you, but they haven't been released yet.
_________________
I came, I saw, I compiled.
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