USB_SOF_HOOK macro executed twice per SOF

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
EmbeddedCreations
Posts: 4
Joined: Sun May 13, 2012 11:37 pm

USB_SOF_HOOK macro executed twice per SOF

Post by EmbeddedCreations » Mon Jun 03, 2013 11:26 am

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.

EmbeddedCreations
Posts: 4
Joined: Sun May 13, 2012 11:37 pm

Re: USB_SOF_HOOK macro executed twice per SOF

Post by EmbeddedCreations » Mon Jun 03, 2013 12:28 pm

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.

Post Reply