Page 1 of 1

USB_SOF_HOOK macro executed twice per SOF

Posted: Mon Jun 03, 2013 11:26 am
by EmbeddedCreations
I'm trying to get the alternate oscialltor calibration routine using the timer working in my application, and was running into some weird issues. I found that the USB_SOF_HOOK was being executed twice per frame, a couple microseconds apart when there is no data, or separated further if there is data.

In these captures, I have the USB_SOF_HOOK macro set to toggle the state of the "DEBUG2" line. I'm using the hid-mouse application with a attiny85 running at 16.5MHz, calibrated using osccal.o

Image
Image

Has anyone seen this behavior? I'm trying to keep the USB_SOF_HOOK macro as short as possible, but now it seems I'll have to add some check to make sure the code is executed only once per frame.

Re: USB_SOF_HOOK macro executed twice per SOF

Posted: Mon Jun 03, 2013 12:28 pm
by EmbeddedCreations
I was able to trace this back to using the pin-change interrupt instead of INT0. The interrupt is executed on any change to the pin, not just on the rising edge of the signal that is normally used, and so two interrupts are generated by the SOF pulse.