4
\$\begingroup\$

Implementation of USB isochronous transfers in (at least some) STM32 microcontrollers has a very weird feature.

It's called EONUM (Even/Odd frame) field.

Basically, the value of the field determines on which frames - odd or oven - isochronous transfers will be received by the microcontroller. So, if you're sending your data every frame, unless you flip the value of the field every frame, you'll get exactly 50% packet "loss".

Flipping the field every frame looks really troublesome, and I can't really see how this feature is useful in any way. The manual barely mentions the feature (search for EONUM, SODDFRM or SEVNFRM), but provides no explanation whatsoever.

This looks somewhat similar to data toggle synchronization for e.g. bulk transfer (which is mandated by the standard), but from what I can tell, the USB spec says nothing about such or similar kind of synchronization for iso transfers (my STM32 processor supports full speed only, so PID sequencing has nothing to do with it, either).

The data transmitter and receiver must have their sequence bits synchronized at the start of a transaction. The synchronization mechanism used varies with the transaction type. Data toggle synchronization is not supported for isochronous transfers.

High-speed, high-bandwidth isochronous and interrupt endpoints support a similar but different data synchronization technique called data PID sequencing. That technique is used instead of data toggle synchronization. Section 5.9.1 defines data PID sequencing.

In the end, I simply set EONUM accordingly to current frame number in SOF handler to achieve loss-free transfer.

Can anyone explain the purpose of the feature?

You can find a few mentions of people battling with this feature over the internet, e.g. here: http://www.chibios.com/forum/viewtopic.php?f=16&t=926

\$\endgroup\$
2
  • \$\begingroup\$ chibios.com/forum/viewtopic.php?t=926 \$\endgroup\$
    – Andy aka
    Dec 12, 2016 at 14:47
  • \$\begingroup\$ @Andyaka I've seen that thread (even provided the link in my question). It has some interesting tips, but I still couldn't find the purpose of the feature there. \$\endgroup\$
    – WGH
    Dec 12, 2016 at 16:38

1 Answer 1

3
\$\begingroup\$

The feature is there so that you don't have to worry that the buffer from which you're reading/writing the data is being overwritten with new data. You're expected to have two buffers and swap them over yourself, you're reading/writing one in software whilst the hardware is writing/reading the other one.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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