Like Korona has stated, the 1024 separate frames are for periodic transfers; mice, keyboard, cameras, etc.
The way that you should create your schedule is to have the controller execute any periodic transfers first, then move to the Control/Bulk schedule.
For example, here is a simple image I posted on this forum a while back:
It uses the first 32 frames. Side note: Since there are 1024 actual frames, using this example, you simply initialize the first 32 as show, then next 32 exactly the same, etc. (32 * 32 = 1024)
The vertical arrows point to the first Queue Head that will be executed in that frame. Then the horizontal arrows, pointing to the left, point to the next Queue Head, continuing until the last Queue Head is executed, this QH being QH1 shown above.
This schedule only has the following Queue Heads, one each of: QH32, QH16, QH8, QH4, QH2, and QH1.
Six (6) total QHs in the whole (empty) schedule. Period, not counting the fact that QH1 then points to a set of Control/Bulk QHs.
Now, by inserting (linking) QHs into one of these six (6) main QHs, you can have something executed at a certain interval.
For example, insert a QH into QH16 and the controller will automatically execute that QH every 16ms, period. Assuming that as soon as it is executed, you update the TDs with in it, new TDs will be executed again in another 16ms. There is no need to poll for time, no need for your code to calculate time, the controller does it all for you.
If you need something executed every frame, link to QH1. If you need something executed every other frame (2ms), link to QH2, etc.
Granted, this schedule shown has a max (or min) frequency of 32ms. If you have a device that needs less frequency, simply create a schedule using the first 64 entries which will now add a single QH at 64ms.
QH64, QH32, QH16, QH8, QH4, QH2, and QH1.
Or use the first 128 entries:
QH128, QH64, QH32, QH16, QH8, QH4, QH2, and QH1.
Or use all of them separately:
QH1024, QH512, QH256, QH128, QH64, QH32, QH16, QH8, QH4, QH2, and QH1.
This will give you the ability to have something executed every second, half second, quarter, etc. The whole periodic schedule has a total of 11 main Queue Heads. Period.
Now all you have to do, as far as periodic transfers are concerned, is call an insert queue function as such:
insert_queue(pointer to schedule, frequency);
The "pointer to schedule" is simply a pointer to the schedule you have, and frequency is a number, power of two (1, 2, 4, 8, etc) of which queue you want to place it in, in turn having the schedule executed every "frequency" milliseconds.
If you want to get more technical, you can even create a schedule with a more detailed frequency. For example, what about "odd" frequencies? By odd meaning not a power of 2.
Let's look at the example again:
The left half is exactly the same as the right half, except for the entry at 32. What it I only modify the right half by inserting a queue between QH8 at 24 and QH4 at 20, let's call it QH24, this Queue Head will be executed every 24th ms.
A few notes about the "odd" entry at QH24:
1) Technically, you would want QH24 to be executed before QH8, so you would swap them. 24 would point to QH24, which would point to QH8, which would point to QH4, etc.
2) Second, if you use the example above, you cannot simply copy to the next 32 entries and expect QH24 to be accurate. It now would be 32 away from this one instead of 24. In every copy, you would modify the appropriate half. For example, in the first 32, QH24 is at 24, but in the second set of 32 it is now at 16, the third set it is at 8, etc. But you get the idea, correct?
Does this make sense?
Ben
-
http://www.fysnet.net/the_universal_serial_bus.htm