Pic18F2455 and USB .. Need some lights to find my bug

Thread Starter

ackn

Joined Jan 3, 2012
1
Hi,

I have developped an application on PIC18F2455 that sends quotation on usb.
the application itself is running pretty well, except that I have a problem on the USB stack that happens quite a lot.
The stack Hangs on the PIC.

What the application does :
The pic received from the PC through USB commands like Init, start, stop
whn the Pic is in start mode, it reads an digital encoder and a push button, the encoder modifies the value displayed but the 7-Seg led display, wile sending to the PC the value. and the button validate the value, and put itself in a stop state

every time the problem appears, is after the validation, when the PC sent a start or anything else, the PIC doesn't receive it.
on more 200 "hung" only once the problem occurs when changing the value, meaning that the PC didn't receive new values and validation, and the pic couldn't receive the init command.

As the code has a WatchDog (I have tested it) I came to the fact tat the application is still running properly, but the usb stack, tells him there is no data.

The application is in polling mode, this is the only thing I remember I have change on the default setting I have found in the usb_config.h

As I cannot force the application to hang, I cannot debug it...
Can you enlighten me what could cause the usb stack to freeze and where to look ?

thank you

yves
 

ErnieM

Joined Apr 24, 2011
8,362
Does your main loop look something like this:

Rich (BB code):
    while(1)
    {
        #if defined(USB_POLLING)
        // Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
                          // this function periodically.  This function will take care
                          // of processing and responding to SETUP transactions 
                          // (such as during the enumeration process when you first
                          // plug in).  USB hosts require that USB devices should accept
                          // and process SETUP packets in a timely fashion.  Therefore,
                          // when using polling, this function should be called 
                          // regularly (such as once every 1.8ms or faster** [see 
                          // inline code comments in usb_device.c for explanation when
                          // "or faster" applies])  In most cases, the USBDeviceTasks() 
                          // function does not take very long to execute (ex: <100 
                          // instruction cycles) before it returns.
        #endif
                      

        // Application-specific tasks.
        // Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();        
    }//end while
 
Top