Page 1 of 1

Code in for loop outside of if (usbInterruptIsReady()) {...}

Posted: Mon Jun 27, 2011 8:17 am
by yardleydobon
Is it not OK to do work in the for loop outside of the if (usbInterruptIsReady()) code block?
I have code between wdt_reset() and usbPoll(). Sometimes the device enumerates correctly
but usually not. Why doesn't this work or why shouldn't I do this? Does the amount of
work done there matter? Do I need to call wdt_reset() multiple times?

Code: Select all

        for(;;)
        {
                wdt_reset();

                //doing some work here
                foo = froobulate(foo, bar, baz);

                usbPoll();
                if (usbInterruptIsReady())
                {
                        my_report.foo = foo;
                        usbSetInterrupt((void *)&my_report, sizeof(my_report));
                }
        }

Re: Code in for loop outside of if (usbInterruptIsReady()) {...}

Posted: Wed Jun 29, 2011 10:43 pm
by ulao
Use the code below, this may help a little.

When ( ! usbInterruptIsReady() ) , You are limited to a very small amount of code space before the next pull must be done. I have tried using that section of code to preform a check on the d- line. My need was for a line Low for x amount of time. I realized there was little room to do anything. The amount of time is much less for Win7 then XP. Almost no time at all!. I added a cli and sli to try to get more room but still was not enough. I would like to know how to cheet this, as thus far I have not had much luck.


Code: Select all

//You can put anything here you want but you still have a limit from what I know. 
// i have never hit it and its well over a second.

while (!usbInterruptIsReady()){   /*  limited to a short amount of time.   */  usbPoll();} 

//You can put anything here you want but you still have a limit from what I know. 
//i have never hit it and its well over a second.