After thinking about this all night as I tossed and turned (something I do frequently when thinking of a problem), I think I've figured it out. Essentially the mainline code will handle all the USB transactions in an infinite loop. That will ensure the quickest possible handling of host requests. In the ISR I will read my keypad, figure out what I need to send, and stuff it in the buffer. It should take very little time (comparatively) so I should end up ok. I'm still confused by much of the professor's custom macros, but at least I feel like I have more of a chance of using the code successfully now. Thoughts? Original post follows for reference. Yes, I top posted, but this is really a mostly free standing post. Josh -- A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. -Douglas Adams On 12/18/05, Josh Koffman wrote: > Alright, I've been working my way through the USB example code (thanks > Xiaofan!) located here: > http://pe.ece.olin.edu/ece/projects.html specifically lab2 at > http://pe.ece.olin.edu/ece/projects/lab2_18F2455.zip > > I haven't had the chance to breadboard and play with it yet, but the > more I read it, the more confused I get. Part of the problem is that > he's defined a bunch of macros that do things I don't understand at > all. Regardless, most of that happens in the USB code that I'm not > trying to decipher at the moment. > > My current confusion revolves around the interrupt routine. It seems > he doesn't have any! It seems that he's setup TMR0 and is polling for > the interrupt flag, near as I can tell anyway. I think that the best > way to deal with will be with actual interrupts in my final > application. > > So what I'm looking for...has anyone else been reading the code? Is my > above interpretation true? Should I decide to use interrupts to handle > the USB stuff, I'm a little unsure of the best way to handle it all. > It seems there are two parts to this, the general USB housekeeping, > and then stuffing bytes into the buffer to be sent as keystrokes. the > keystrokes I should just be able to decide on my own. If I call that > more often, I get a quicker response time on the keys. The USB > housekeeping (ServiceUSB in his code) is a bit more confusing...I have > no idea how often I need to call it to keep the host happy. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist