I've been reading and experimenting with the USB hardware (see my project at swfischer/Kinetis-L-FreeRTOS-GCC · GitHub) and the USB BDT table still confuses me. My confusion is related to the whole EVEN/ODD thing. As I've read, the BDT table contains two 8 byte entries per end-point per direction IN/OUT. This math works out and space for 16 end-points results in 512 bytes in the BDT. So, the two 8 byte entries, as I understand it, are for double buffering the end-point data stream, which sound fine. The confusing part is that there are two sets of control data (the buffer descriptor) for the two buffers. Each buffer descriptor contains a DATA0/1 field, but only one buffer, so how does the double buffering work? Does the DATA0/1 field denote which of the two 8 bytes entries is being used and, if so, what happens when the two DATA0/1 field don't match?
Also, I haven't found a good description of the buffer descriptor DTS bit. I know DTS means "Data Toggle Synchronization" but is there a good description of what DTS is and when you should or should not use it?
Steven
See page 26 of http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF for a diagram of the Endpoint even/odd buffering.
Remember that even and odd entries don't necessarily match with DATA0/1 - the control field defines this, so basically the double buffers are used to allow filling/emptying one while the previous is being processed by the USB controller. [Furthermore, it is possible to modify the buffers used on the fly so one could also use multiple such RAM buffers, although 2 adequate for mayimum full-speed throughput].
DTS enables the controller's data toggle mechanism - it is used by control and bulk endpoints but not isochronous. It causes the controller to respect DATA0/1 togging when sending frames and checking of the correct DATA token on reception.
You can use the uTasker Kinetis simulator to simulate the USB device and see the internal workings of the flags, buffer descriptors, interrupts, etc. in case you want to study exactly how things operate (it will simulate all KL and K parts with USB using VisualStudio and cross compile to all Freescale boards - inkl. FRDM-KL25Z using GCC (without libraries), CW, KDS, IAR, Keil, Atollic, Rowely Crossworks, Green Hills or CooCox).
Regards
Mark
Kinetis: µTasker Kinetis support
KL25: µTasker Kinetis FRDM-KL25Z support / µTasker Kinetis TWR-KL25Z48M support
Composite USB: µTasker USB Device Configuration
USB User's Guide: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
For the complete "out-of-the-box" Kinetis experience and faster time to market
Mark,
Thanks for pointing out the uTasker reference. The diagram is helpful and I will spend some time looking into the simulator.
A continuing question though is if the DATA0/1 field does not necessarily match the even/odd-ness, what does the field do? For instance, if the EP1 RX EVEN BD entry is configured for DATA1 (the seemingly odd state for the even BD entry), is the BD entry now referring to a different buffer (maybe the buffer pointed to by the EP1 RX ODD BD) or what?
Sorry, if I'm belaboring the point here but I'm just trying to get a better understanding.
Thanks,
Steve.