First of all, thanks everyone for the response so far. You really helped me out! But again, i have another question. I managed to get USB HID working under FreeRtos. However, during enumeration some USB hosts require a (small) response every 100uS. I tried to increase the tick rate, but when set the value to 10.000, the whole OS stopped working. Apparently the OS is consuming too much CPU now. What is the best way to solve this problem? I`m thinking about using an external timer interrupt every 100uS. But i was wondering if there are more/better ways to do.
I don’t know anything in USB that requires this resolution. But if you really need to do that use a hardware timer.
Well, actually at 1mS refresh rate (using the delayUntil) gives me a message in windows that the USB device cannot be started (code 10). When i put the function in a continuous loop, without delay calls, then it works correctly. But then off course the OS gets stalled because the USB task consumes all of the processing power. The strange thing is that with the 1mS delayUntil, the USB does work correctly on my notebook. But not on my PC. Anyway, I`m thinking to use the USB on board interrupts instead of a polling loop. I think that should work. Thanks for the reply.
Delays on the order of microseconds almost certainly have to be done with either a hardware timer (and you just monitor the count value) or with a timed sequence of instructions (like NOPs). But for USB work (and I’m just getting to the "oh, I see" stage with that) you really have to use interrupts. As you’ve discovered, it’s very timing-sensitive, but if you’re on the device side, the timing is pretty much not up to you. The reason to use an RTOS is so you can do something else while you’re waiting for the host to demand that you do the next thing, within the next X microseconds. You can poll, but you’re wasting a lot of time. For very initial development, I had fair results by calling the ISR in a tight loop from an ordinary task. However, this risks having things work (or not) because of random lucky (or unlucky) timing coincidences. For example, I was able to get enumeration to work this way, but only if I had certain debugging messages turned on. The problem was, with the messages, I was pausing long enough for a STATUS phase to complete, but without, I was doing the next thing too soon. The correct solution is to key off the STATUS-PHASE-COMPLETE interrupt.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.