Sub millisecond event?

Hi,

I have searched high and low and I can’t find what I am looking for.

My goal is to fire an event on a sub millisecond level (in the region of every 20 MICROseconds!)

Is this even possible does anyone know?

The timer or Thread.Sleep only gets me to 1ms, I have seen Output Compare but this can only change a pin status and not fire an event/interrupt, or have I missed something on these?

I have found Thread.SpinWait in the normal DNFW but I guess this will just put the processor into a flat spin until finished. (that and it’s not implemented in the DNMFW!)

I know the DNMFW is not real time and that is fine for this I just need to get as close to 20uS as possible. .

My last real option is to put the processor into a While(true) loop with a ‘tick’ test but this is just messy and has lot of problems IMHO…

Thanks in advance and if I have been having a ‘blokey’ look a link to the correct page would be very, very welcome!

Kind regards,

Andy

So what is the point of firing an event every 20us if you can’t respond to them that fast? Maybe if you explain what your trying to accomplish someone might know a different way to do it.

Jeff is right. What kind of thing that needs events at 20 us rate? This will keep the processor very busy to do anything else even if there was no NETMF.

Hi,

Thanks to you both for your reply. I should have explained a bit better, sorry!

What I am trying to do is set up a system for a simple timer array.

So for example there is an array of 50 timers and on each ‘clock tick’(around 20uS) then if it needs to it will iterate through the array and reduce the timers by 1. If it can’t iterate through the array at that moment in time then it will use a counting semaphore to keep track and come back to it as soon as it can.

Hence my short event handler will make the call to iterate or semaphore++!

Things don’t need to be real time, just as close as we can get it! There will be regular times where no timers are due to expire for several tens/hundreds of milliseconds and it can run the GC/housekeeping at these points.

I hope that this makes sense, but if not then do please say,

Kind regards,

Andy

Hmm, I couldn’t get one output to just toggle at 25us to generate a 20KHz signal…

And I was using the outputcompare, which is native code(right?), so running anything that fast in managed code won’t be possible…

OK, but NETMF has all sorts of timers built into it. What are you trying to accompliosh with your timers?

Hi,

I have to be honest and say I am coming to the same conclusion…

I have just been running some further tests and iterating through an array of 32 items I can get it down to a process time of 45260 ticks, which if my maths works correctly is 4.5ms (10,000 ticks in a millisecond?)

Firstly is this correct?
Secondly if this is correct then I’m back to the drawing board… :frowning:

//A

Thanks Jeff -

There are pointers to functions to run when the individual timers expire. This is what the rest of the time is for.

//A

I think you need to look at what is built into NETMF to call functions at a given time, like the ExtendedTimer. What is it you need to accomplish that the built in timers won’t do for you. Keep in mind, that no matter what your not likely to get sub millisecond timing.