pico-feedback icon indicating copy to clipboard operation
pico-feedback copied to clipboard

Documentation: USB Double Buffering

Open rkapl opened this issue 4 years ago • 1 comments

From the RP2040 Datasheet ef82dc8-clean, it is not immediately clear how to avoid race conditions in USB double buffering mode when updating the buffer control "register".

Currently, it seems that the proper solution is to use 16-bit access (I have not tested fully, but is seems to work).Given the availability of set/clear aliases on rp2040 HW, user might be tempted to use them (Well, I was :)), but they do not work. They work only as a simple alias.

I suggest

  • Document the proper update sequence for double-buffered mode. A 16-bit write to upper/lower half?
  • Clarify the status of DPSRAM. Do aliases work? What accesses are atomic w.r.t the controller? Given the "first write data, then set the available bit" warning in 4.1.2.5.3, it seems it is not really atomic in some cases.
  • Maybe emphasize that "Narrow IO Register Writes" limitation does not apply for DPSRAM. But for me, " with DWORD, WORD and BYTES accesses supported" is clear enough.
  • If word access should be used, provide proper aliases/unions in the SDK.

Now some very minor gripes. In general, the buffer control register documentation is a bit terse compared to the above-average level of the rest of the manual. E.g.:

  • How are the available and full bits related? It is sort-of described in later section, but small note would be nice here
  • Is the buffer select accessible somewhere or does SW has to track it? (I assume it is internal)
  • Bit 26 is probably missing "only valid for double buffered" notice

Best regards, and thanks for the great hardware

rkapl avatar Feb 08 '21 21:02 rkapl

bump @liamfraser

kilograham avatar Oct 21 '21 22:10 kilograham