I'm developing some high-speed USB firmware for the STM32F746VG, and on page 1411 (under section 37.16.3, step 2), it tells me that I should enable start of frame interrupts.

I know that usb hosts send a start of frame packet once every 125uS in high-speed mode, but why should my device care about SOF packets, aside from timekeeping? What could I possibly do in an interrupt service routine that would trigger on every start of frame packet?

  • \$\begingroup\$ You will know when you actually will need it :) It's a synchronization signal, like in any asynchronous communication.. \$\endgroup\$ – Eugene Sh. May 27 '16 at 19:50
  • \$\begingroup\$ That's its primary purpose? It seems weird then that the datasheet tells me that I "must" enable the SOF interrupt. \$\endgroup\$ – John M May 27 '16 at 19:55
  • \$\begingroup\$ Well, I am not going to dig into the datasheet too deeply, but I would imagine that the host controller is triggering data transfer once SOF is detected. So it needs an interrupt for that. It's like for DMA transfers you sometimes need to enable the triggering interrupts even though you are not going to explicitly handle them. \$\endgroup\$ – Eugene Sh. May 27 '16 at 19:58

I believe the original 1 ms (1 kHz) start of frame interrupt was to give devices to cheap but accurate timing. The accuracy spec on that is rather tight.

If you don't need to do accurate timing, or you have your own crystal, then you don't need to know when USB frames start. The host initiates all transactions, even when you send, so your hardware and firmware will know that way when to do what.

I've created a bunch of USB devices, and have not used start of frame detection at all so far. If you are using a canned library, then possibly the library uses SOF for some internal timing or to know when to do housekeeping. If the library docs say you need SOF, then you need SOF.

| improve this answer | |
  • 3
    \$\begingroup\$ @johnny_boy Please don't accept the first answer so quickly. It discourages others from joining in on the conversation since the 'accept' bonus is already taken. 24 hours is a reasonable time to see if more answers emerge. \$\endgroup\$ – Adam Lawrence May 27 '16 at 20:49
  • \$\begingroup\$ @AdamLawrence Thank you for the advice. Do you think I ought to unaccept the current answer and see if some other good ones appear as a result, or is it too late for that? \$\endgroup\$ – John M May 28 '16 at 14:32
  • 1
    \$\begingroup\$ @johnny_boy I would just keep it in mind for your next question. \$\endgroup\$ – Adam Lawrence May 28 '16 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.