I recently purchased a digital LED strip that I use with my Arduino Mega and it works fantastically. The protocol that it uses is highly timing dependent so the retailer says that it cannot be used with the Netduino. Of course, I take this as a challenge and I want to get it working on the Netduino for a lot of reasons but I know there are several issues that I'm going to run into related to timing.
First, the garbage collector will destroy the protocol if it runs while I'm updating the strip.
Second, as far as I can tell there's no guarantee that my code won't get interrupted by another piece of code while it is running.
The code really will consist of setting a line high or low, waiting a very specific period of time, and then setting it high or low again. Repeat over and over for a few milliseconds and then we can go back to executing regular code.
So... what I want to know is:
- Is it possible to stop the garbage collector? I can do allocationless programming as some people have suggested but I want to know if there is a way to guarantee that the GC won't run.
- Is it possible to tell the Netduino or the .NETMF that only one thread can run for a short period of time? Sort of like a critical section that will do all of the timing dependent code.
- Are there other .NETMF gotchas that might cause the timing to be imperfect?
- Will this just require me to write native code? If so, that's no big deal but I'd rather start there if these other ideas aren't practical rather than bang my head against a wall for a few days while I come to that realization.
Thanks,
Tim